PDA

View Full Version : When use Ext.Ajax.request instead of Store proxy



Periyasamy A
18 Sep 2012, 2:03 AM
Which situation use store proxy instead of Ext.Ajax.request

how to handle common request and response handler

The requirement is one common place to handle all request and response (All the request need to be validated and all the response need to be validated)

friend
18 Sep 2012, 6:38 AM
In your application setup/initialization, you can register global Ajax handlers:



function globalAjaxHandler(connection, response, options) {
if (response.status == 404) {
// do some URI not found handling...
}
}

Ext.Ajax.on("requestcomplete", globalAjaxHandler, this);
Ext.Ajax.on("requestexception", globalAjaxHandler, this);


This function will intercept all Ajax requests done by any objects/proxies/etc. Note that you can manipulate the response object prior to it being passed on to the caller.

Periyasamy A
19 Sep 2012, 8:46 AM
Thanks for your reply.

Which is best "Store proxy" or "Ajax.request" for server call

Tim Toady
19 Sep 2012, 11:24 AM
They both do an ajax request. If you need a store for something like a grid/combo and you are getting data from the server than set up the proxy. If for some reason you need to make a request and its purpose is not to load a store than use an ajax request. It is not so much which is better, but when to use them.