Internet Explorer 9 goes into an endless loop while making a recursive ajax call to server. The following code works perfectly in Chrome :
function readMessages() {
// console.log("Starting ajax");
$.ajax({
url : "read-messages",
data: {userId:$('#usedId').val()}
}).done(function(result) {
// console.log("Ajax complete");
$('#messages').append(result);
// console.log("Recursive call - read-messages");
readMessages();
});
};
After the first ajax is completed, IE executes the readMessage() function over and over, without actually waiting for an answer from the server. It seems I should somehow "reset" the request within jQuery (version 1.11.3 used)..
Any help is appreciated
Try setting cache to false:
$.ajax({
url : "read-messages",
data: {userId:$('#usedId').val()},
cache: false
}).done(function(result) {
$('#messages').append(result);
readMessages();
});