I wrote a function that makes an asynchronous query using jQuery.
var Site = { asyncRequest : function(url, containerId) { $.ajax({ url : url, onSuccess: function(data){ $(containerId).html(data); } }); } }
The syntax may be a little wrong as I use notepad, but hopefully you get this idea.
I call the function:
Site.asyncRequest('someurl', container1); Site.asyncRequest('someurl', container2);
Both requests are sent and processed by the server. Two responses are sent back, which I expect. However, I would expect that container 1 and container 2 will contain responses from both requests.
The problem is that only the last answer is displayed, and I cannot understand why. I don't know how jQuery ajax tracks requests / responses, so maybe this is a problem.
Let's say I make 5 or 10 queries, how does jQuery ajax know which answer for which query, and where does it track it?
thanks
user338195
source share