Skip to content

Instantly share code, notes, and snippets.

@wadewegner
Created October 15, 2017 15:13
Show Gist options
  • Save wadewegner/912fb0985db4a70b60fcd649fe48e093 to your computer and use it in GitHub Desktop.
Save wadewegner/912fb0985db4a70b60fcd649fe48e093 to your computer and use it in GitHub Desktop.
function poll() {
var complete = false;
$.ajax({
url: "/api/test",
type: "GET",
success: function (data) {
var message = data.message;
if (message === 'yes') {
complete = true;
status('complete: ' + data.message);
}
},
dataType: "json",
complete: setTimeout(function () {
if (!complete) {
status('polling');
poll();
}
}, 1000),
timeout: 2000
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment