PDA

View Full Version : When does Ext.Ajax actually fail?



gr_great_2000
13 Sep 2010, 2:45 AM
Hello. I would like to ask you when does an Ext.Ajax request actually fail. If my server php script returns anything, then the request is successful. So the only way (?) to fail is to throw some uncaught exception, which is not very elegant.

On the other hand, when you submit a form, throwing an uncaught exception from the script is not enough. You have to return "{success: false}". Isn't that inconsistent?

Any tips? Thanks in advance

Animal
13 Sep 2010, 2:49 AM
Not inconsistent.

Form uses an application level protocol.

Ajax allows YOU to use a protocol to indicate APPLICATION failure. Ajax fails if it really does FAIL. ie: cannot access the server.

Condor
13 Sep 2010, 2:58 AM
Ext.Ajax doesn't process the data, so {success:false} is still a successful response. If you want to signal an unsuccessful response this way then you have to analyse the data in the success handler.

An Ext.Ajax.request only fails if the server responds with a status code <> 200.