Total up the amount of the ajax request and show the ajax response when it is the last ajax response.
In other words, how to use only the response of last sent ajax request.
var req=0;
function ajaxReq(){
req++; /total up the amount of request/
$.ajax({
url: "result.php",
type: 'GET',
contentType: false,
enctype: 'multipart/form-data',
cache: false,
processData: false,
success: function(response) {
if(req==1){ /show the response when this is the last request/
$("#response-element").html(response);
}
req--; /Subtract when every success ajax response/
}
});
}
I using this on viewing messages detail if the user clicked few threads before the response show out it will show the previous thread detail before the current selected thread detail shown out
Any better solution would be nice for sharing