This question is related to this: jQuery recursive ajax poll using setTimeout to control the poll interval, but slightly different and I cannot figure out why.
function _poll(n) {
$.ajax({
url: "/check_status",
type: "POST",
data: {state: 0},
success: function(xhr) {
var data = $.parseJSON(xhr)
if (data.status == 0) {
poll(n)
}
}
});
}
function poll(n) {
setTimeout(_poll(n), 5000);
}
Like the other question, the request is also sent out crazy. Thanks a lot for the help!
Note, I have to use different names "poll" and "_poll" for other purposes.