PDA

View Full Version : question about formpanel.getForm().submit()



masoud_tamizy
11 Feb 2012, 7:38 AM
i have a formpanel in a window that submit some information to server .
why when server doesn't resend any response ; function in client side (submit response) decides to executing success block ?

mitchellsimoens
12 Feb 2012, 7:48 AM
Resend any question? Remember, success can mean a 200 status code response also.

masoud_tamizy
12 Feb 2012, 8:14 AM
Resend any question? Remember, success can mean a 200 status code response also.
excuseme , when server send null response (without response) to client . client desides to go to success block .
how can i check status code ?
thank you mitchell

friend
13 Feb 2012, 10:35 AM
Note the action.response object:


form.submit({
success: function(basicForm, action) {
var httpStatus = action.response.status;
var httpStatusText = action.response.statusText;
},
failure: function(basicForm, action) {
switch (action.failureType) {
case Ext.form.Action.CLIENT_INVALID:
Ext.Msg.alert('Validation Failure', 'Please check all fields for valid values.');
break;
case Ext.form.Action.CONNECT_FAILURE:
Ext.Msg.alert('Failure', 'Communication failure.');
break;
case Ext.form.Action.SERVER_INVALID:
Ext.Msg.show({buttons: Ext.Msg.OK, icon: Ext.Msg.ERROR, msg: action.result.msg, title: action.result.title, width: 300});
}
}
});

masoud_tamizy
17 Feb 2012, 7:24 PM
Note the action.response object:


form.submit({
success: function(basicForm, action) {
var httpStatus = action.response.status;
var httpStatusText = action.response.statusText;
},
failure: function(basicForm, action) {
switch (action.failureType) {
case Ext.form.Action.CLIENT_INVALID:
Ext.Msg.alert('Validation Failure', 'Please check all fields for valid values.');
break;
case Ext.form.Action.CONNECT_FAILURE:
Ext.Msg.alert('Failure', 'Communication failure.');
break;
case Ext.form.Action.SERVER_INVALID:
Ext.Msg.show({buttons: Ext.Msg.OK, icon: Ext.Msg.ERROR, msg: action.result.msg, title: action.result.title, width: 300});
}
}
});
thanks . this is very good , but even with empty response leads to Status 200 !

friend
20 Feb 2012, 5:19 AM
If you're getting an HTTP status code of 200, then the server successfully returned a response and the client is happy with that.

You now need to examine exactly what's being returned by the server. If you haven't already, use Firefox/Firebug or Chrome's Developer Tools to take a look at the actual response.

To learn more about exactly what's returned via the action parameter of the success/failure method, you can dump the contents of the object, where console.log(msg) works in Firefox/Firebug but not IE:




// this will dump the contents of the 'action' object to the Firebug console.
// use 'var obj = action.response' to dump the child 'response' object.
var obj = action;

console.log('===== >>> START Object enumeration ===========');
for (props in obj) {
console.log('property: ' + props);
console.log('value: ' + obj[props] );
console.log('****************************************\n\n')
}
console.log('===== <<< END Object enumeration ===============');


Anything which displays a return value of [Object] is a obviously a child object, so just change the 'obj' variable to any dot-notated child object you want to dump.