PDA

View Full Version : Interference with two AJAX requests



Crusy
9 Jun 2009, 7:04 AM
Hi there,

I have two AJAX-requests, and both of them are delivering the correct response if I open the URLs directly. But if I call those two URLs in the mentioned two separate requests, both of them are receiving the response from the first request. Here's my code:



function retriveNewCategory( checkBoxId )
{
retrieveFilteredIdeas( baseUrl + checkBoxId );
retrieveFilteredCustomers( checkBoxId );
}

function retrieveFilteredIdeas( fromUrl )
{
var ajaxRequestIdeas = Ext.Ajax.request
({
url: fromUrl,
disableCaching: false,
success: handleFilteredIdeas,
failure: function(){}
});
}

function retrieveFilteredCustomers( categoryId )
{
var ajaxRequestCustomer = Ext.Ajax.request
({
url: 'index.php?/' + language + '/shared/ajax/filteredCustomers/' + categoryId,
disableCaching: false,
success: handleFilteredCustomers,
failure: function(){}
});
}
I don't get it, because I even assign those two requests to separate variables, but they do interfere anyway... is there some sort of unique ID I could assign to both of them or something? I do not want to make the application wait for one of those requests before starting the next, as that would not be in the sense of *asynchronous* Javascript^^

Any help appreciated,
Crusy

Animal
9 Jun 2009, 7:11 AM
Are you sure?

Try logging the response in an inline success handler seperately in each call.

Crusy
9 Jun 2009, 7:21 AM
Try logging the response in an inline success handler seperately in each call.

you mean something like


function retrieveFilteredCustomers( categoryId )
{
var ajaxRequestCustomer = Ext.Ajax.request
({
url: 'index.php?/' + language + '/shared/ajax/filteredCustomers/' + categoryId,
disableCaching: false,
success: function(xx)
{
alert(xx.responseText);
},
failure: function(){}
});
}? Same behaviour..

Animal
9 Jun 2009, 7:23 AM
Well

console.log("from retrieveFilteredCustomers: " + xx.responseText)

so you know who's getting what back

Crusy
9 Jun 2009, 7:49 AM
I already checked the response with Firebug's GET-response display, but I tried your solution just to double check - both requests show the same response.

Once I open the URLs directly from Firebug (so they are definetly the URLs used by the requests) by right-clicking->"open in new tab", I see the correct response.

BTW: I'm using ExtJS 2.2, Codeigniter as the server-side framework, Aptana as editor. This is on a local host right now (the one Aptana comes with), I will try the live server in a couple of minutes

Crusy
9 Jun 2009, 7:54 AM
...OK, it seems to work on the live-server :D
I will digg into this and let you know if I find something. There has to be some reason for this, even if it's Aptana- (or whatever-) based

Thanks a lot!