View Full Version : Form Submit always success

2 Sep 2010, 6:06 AM
Hi, I face a very rare problems that my form submit always success even I set respond

Below is my code for submit handle and jsp page

submitHandler: function () {
url: 'test.jsp',
params: this.getValues(),
success: function(f,a){
Ext.Msg.alert('Success', "Your Case has been successfully added");
failure: function(f,a){
if (a.failureType === Ext.form.Action.CONNECT_FAILURE){
Ext.Msg.alert('Failure', 'Server reported:'+a.response.status+' '+a.response.statusText);

if (a.failureType === Ext.form.Action.SERVER_INVALID){
Ext.Msg.alert('Warning', a.result.errormsg);




Anyone have any ideas? Thanks.

2 Sep 2010, 6:09 AM
success:false is a logical failure (a form submit would interpret this as failure), but a connection (=Ext.Ajax) doesn't process the content, so as long as it receives a status=200 the response is valid.

2 Sep 2010, 6:16 AM
Thanks, I understand that. However, how can I set that submit is false, for example if i want to do manual return error on form submit at server side and return back that message to user.

2 Sep 2010, 6:22 AM
You will have to evaluate the response in the the success handler to see if it is really success:true.

ps. Why are you not using the build-in form.submit?

2 Sep 2010, 6:23 AM
Can you show me reference for that or coding for that. I still do not know how to do that.

Thanks a lot.

I just have a quick view and see this code, is it the particular way to do as your suggestion:

var jsonData = Ext.util.JSON.decode(oResponse.getResponseHeader.JSON_STATUS);
if (jsonData.success === false) {
//show error

2 Sep 2010, 6:28 AM
What is oResponse.getResponseHeader.JSON_STATUS? You should be using:

success: function(response){
var jsonData = Ext.decode(response.responseText);

2 Sep 2010, 6:35 AM
Thanks so much, it is done as your code show. You help me a lot.