PDA

View Full Version : form.submit returns success, but fails?



hallikpapa
12 Aug 2009, 11:24 PM
When I save a form, it execute php code, and returns simple JSON that says

But it hits the failure function instead? What am I missing?


Ext.getCmp('user-details-form').getForm().submit({
params: { save: 'user' },
waitMsg: 'Saving...',
success: function(f,a){
Ext.Msg.alert('User Saved');
},
failure: function(f,a){
Ext.Msg.alert('Error Saving User');
}
});
Relevant section of php code

$response = array("success"=>true);
return json_encode($response);
} catch(Exception $e)
{
$response = array("success"=>false,
"message"=>$e->getMessage());
return json_encode($response);
}

Firebug shows this returned, but the alert pop up says the "Error saving user" message from the failure function
{success:true}

I have setup a function that both success or failure call, and it just checks to see if the value returned is true or false and does the pop ups based on that, but I figured I should find out why it's always showing fail when it comes back. Breaking in firebug shows a.result.success = true; a.result being an object.

What have I missed?

Animal
13 Aug 2009, 1:18 AM
Is it a file upload?

hallikpapa
13 Aug 2009, 5:30 AM
no it's a regular form submit, posting of data.

Animal
13 Aug 2009, 6:00 AM
You will have to set a breakpoint in Ext.form.Action.Submit where it processes the response and step through.