Issue
While working with a requisition in ExtJS, I found myself in a strange situation. My PHP backend was returning correct response, like this:
{
  "success": true,
  "id": "<some_id>"
}
For success
And...
{
  "success": false,
  "msg": "<error_msg>"
}
For failure
But, even with something like this, in correct structure, my code was not working. In submit function from form, the form to wait for requisition is putting success and failure listeners in configuration object from function, like this:
form.getForm().submit({
  ...,
  success : function(me, action){
    // code...
  },
  failure : function(me, action){
    // code...             
  }
});
Solution
And, what is the answer for this big question? It is simple!
The form request listeners work specifically with response format. So, if request is success, insert "success": true in your JSON response object. Otherwise, insert "success": false, that function will recognize that must call what is passed in failure configuration.
Conclusion
In forms like this, simply follow this principle:
To call what have been passed in
successattribute in the configuration object fromsubmit():
{
  "success": true,
  ...
}
To call what have been passed in
failureattribute in the configuration object fromsubmit():
{
  "success": false,
  ...
}
    
Top comments (0)