I recently developed a project when I sent multiple ajax requests on one aspx page. I also set a timer, this request occurs with an interval of 5 seconds. Everything seems to be working fine until the reaction starts. I know that I could do the same with one request, but I wonder why this is happening. I looked around the Internet, but have not yet found a solution. I now actually adopted this coding style of how to make a single request with multiple results, but I'm curious, and I really want to know how to make multiple ajax requests, as the answer will not be mixed. This is my sample code:
$(document).ready(function () {
var a = setInterval("request1()", 5000);
var b = setInterval("request2()", 5000);
});
function request1() {
$.ajax({
url: 'ajaxhandler.aspx?method=method1' ,
beforeSend: function (xhr) {
xhr.overrideMimeType('text/plain; charset=utf-8');
},
success: function (data) {
alert(data);
}
});
}
function request2() {
$.ajax({
url: 'ajaxhandler.aspx?method=method2' ,
beforeSend: function (xhr) {
xhr.overrideMimeType('text/plain; charset=utf-8');
},
success: function (data) {
alert(data);
}
});
}
source
share