PDA

View Full Version : Facing problem with Ext.Ajax.abortAll() function



digvijayun
13 Jan 2013, 11:27 PM
Hi,
I have tried a simple example to use Ext.Ajax.abortAll()

I am sending asynchronous Ajax request in loop and aborting all before the 6th one

LSwitch = false;
GRequestCount = 0;

for(var LLoopIndex = 0; LLoopIndex<10; LLoopIndex++)
{
if((LLoopIndex == 5) && (! LSwitch))
{
console.log('aborting all the ajax requests');
Ext.Ajax.abortAll();
LSwitch = true;
}

Ext.Ajax.request({
url: 'http://localhost:8081',
method : 'GET',
async: true,
params : '____ReqNo' + GRequestCount,
success: function(response, options)
{
//alert('The request is successfull');
},
failure: function(response, options)
{
//Request failed throw exception
//alert('Error Occured -- ' + response.getError());
}
});
GRequestCount ++;
}

The output in chrome debugger:
41249

I dont understand this the
6th request is successful and all the others after that are also getting canceled.

It is a bug or I am doing something wrong??

Thanks.

friend
14 Jan 2013, 5:25 AM
According to the documentation, Ext.Ajax.abortAll() (http://docs.sencha.com/ext-js/4-1/#!/api/Ext.Ajax-method-abortAll) abortsall active requests. Therefore, you only need call the method once.

digvijayun
14 Jan 2013, 6:30 AM
Yes exactly, I am calling the abortAll() once when the loop index is 5 i.e. before sending Ajax request for the 6th time.

It should block all the requsts sent before the 6th one (If you see the screenshot it is doing that) and the 6th request also gets completes (as expected so far).

The only problem is I am not able to understand why it is cancelling all the requests sent after the 6th request.

May be it is getting cached because I am sending the request on the same URL each time.

If I change the URL for each request it works fine..