PDA

View Full Version : ABorting AJAX request



harjits
15 Nov 2012, 6:36 AM
Hi there,

I'm using the following code to abort a ajax request but it doesn't seem to work. I do see that the load mask is gone but the results are still being rendered in to the grid



//abort the request Ext.Ajax.abort(searchStore.proxy.activeRequest); //hide any masks var gMask = Ext.getCmp('searchGrid').loadMask; if(gMask && gMask.hide){ gMask.hide(); } }

willigogs
15 Nov 2012, 6:59 AM
Have you tried debugging to check that searchStore.proxy.activeRequest is populated prior to the abort attempt?



console.log(searchStore.proxy.activeRequest)
Ext.Ajax.abort(searchStore.proxy.activeRequest);

harjits
15 Nov 2012, 11:53 AM
yeah, I did. I did find the correct way to do it. It's
store.proxy.destroy() that will kill the request. I'm surprised that the code which I used to kill the request didn't work was taken from sencha documents.

willigogs
15 Nov 2012, 1:13 PM
In the sencha documentation, "searchStore" is the variable name of their store.

So for example:


var exampleStore = new Ext.data.Store({
...Store Config...
});


Then to kill an Ajax call fired by this store:


Ext.Ajax.abort(exampleStore.proxy.activeRequest);

willigogs
15 Nov 2012, 1:39 PM
Be aware that destroying the entire store proxy may also create undesired problems (any other Ajax requests after it's destroyed nay not be successful).

harjits
16 Nov 2012, 7:19 AM
Im totally aware of that because for each request a new object is created. Thanks for the pointer

- Harjit


Be aware that destroying the entire store proxy may also create undesired problems (any other Ajax requests after it's destroyed nay not be successful).