I want to identify which response belongs to which (async) call. In my client web application I have a list of items. Every time the user navigates to an item the application makes an ajax-call to check if the item is up to date. If the user navigates very fast there are several calls (with the same callback-function) waiting for a response. Is there a way in jQuery to identify which response belongs to which call? Or do I have to implement it myself?
So I just found a plugin which seems to solve my problem:
http://docs.jquery.com/AjaxQueue (but there is no download-link today)
I found this way to identify which response belongs to which call:
var xhr = $.ajax({
type: 'GET',
url: 'service.php',
dataType: 'json',
data: data,
async: true,
timeout: 1000,
success: function(xhr)
{
alert('success with callID: ' + xhr.callID);
},
error: function(xhr)
{
alert('error with callID: ' + xhr.callID);
},
complete: function(xhr)
{
alert('completed callID: ' + xhr.callID);
}
});
xhr.callID = ++seqNo;
xhr.itemID = ID;
With this information it should be possible to build my own queue.