Mainul Quraishi Mainul Quraishi - 6 months ago 24
Ajax Question

after each successful response, request again

From my html page, the ajax request response will works like a loop. That mean's when a successful response come back, again a request will go. I did like the following but that works for only 2 consecutive request-response and I also can understand why.

$.get("chat1", function(data, status){
$("#data").html(data);
$.get("chat1", function(data, status){
$("#data").html(data);
});
});


But, i want to make it automatic. How can i do this? FYI: i am trying to implement long polling.

Answer

Use $.get(this) to make the same request again in the success callback function.