lundi 14 avril 2014

Redirecting to Web API after form submission.

I am uploading an image. This is the code of my view:

Code:



Ext.define('MyApp.view.AddCountry', {
extend: 'Ext.window.Window',
alias: 'widget.addcountry',
closable: true,
closeAction: 'destroy',
modal: true,
height: '28%',
width: '45%',
panelStatus: 'add',
panelId: 0,
initComponent: function () {
var me = this;
me.items = [{
xtype: 'form',
headers: { 'Content-Type': 'text/html' },
standardSubmit: true,
layout: 'form',
bodyPadding: '5 5 0',
itemId: 'addCountryForm',
frame: false,
items: [{
xtype: 'textfield',
fieldLabel: 'Name',
maxLength: 25,
enforceMaxLength: true,
allowBlank: false,
name: 'Matrix'
}, {
xtype: 'textfield',
fieldLabel: 'Description',
maxLength: 100,
enforceMaxLength: true,
allowBlank: false,
name: 'description'
}, {
xtype: 'filefield',
name: 'flagImage',
fieldLabel: 'Flag',
buttonText: 'Select Image...'
}],
buttons: [{
text: 'Save',
itemId: 'btnSaveCountry'
}, {
text: 'Cancel',
itemId: 'btnCancelAdding'
}]
}];
this.callParent();
}
});

This is the upload code in my controller:

Code:



SaveWidgetType: function (button) {
var form = button.up('form').getForm();
form.submit({
url: 'localhost/myapp/api/country/addcountry',
waitMsg: 'Please wait...',
success: function (f, o) {
Ext.Msg.alert('Success', o.result.result);
},
failure: function (f, o) {
Ext.Msg.alert('Error', o.result.error);
}
});
}

When I submit the form, it gets redirected to "localhost/myapp/api/country/addcountry" that shows this string:

{"$id":"1","success":true,"result":"Uploaded Successfully.","error":null}Can someone point out the error? If I remove "standardSubmit: true", The wait message keeps rendering. The control gets stuck there.





Aucun commentaire:

Enregistrer un commentaire