21 lines
706 B
JavaScript
21 lines
706 B
JavaScript
|
|
var $status = $('#status');
|
|
/**
|
|
* When the form is submitted, begin checking status periodically.
|
|
* Note that this is NOT long-polling--that's when the server waits to respond until something changed.
|
|
* In a prod env, I recommend using a websockets library with a long-polling fall-back for older broswers--socket.io is a gentleman's choice)
|
|
*/
|
|
$('form').on('submit', function() {
|
|
var longPoll = setInterval(function () {
|
|
$.get('/checkstatus').then(function (status) {
|
|
$status.text(status);
|
|
|
|
//when it's done, stop annoying the server
|
|
if (parseInt(status) === 100) {
|
|
clearInterval(longPoll);
|
|
}
|
|
});
|
|
}, 500);
|
|
});
|
|
|