I am fresh to jQuery\'s implementation of it\'s AJAX methods.
I have a simple setup that accesses two different pages, one which takes 10 seconds to complete (I have
What about something like
I dropped the try catch's and made your setTimeout's to look like check_id = setTimeout(progressCheck, 1000);
function beginLogin(){
var login_url = "http://example.com/home/loginScript";
return $.ajax({
url: login_url,
success: function(data){
$("#result_div").append('' + data + '
');
alert("finished");
},
error: function(a, b, c){
console.log(a)
console.log(b)
console.log(c)
}
});
}
function progressCheck(){
var check_url = "http://example.com/home/checkLoginProgress";
var ajax = $.ajax({
url: check_url,
success: function(data){
$("#progress_div").append('' + data + '
');
},
error: function(a, b, c){
console.log(a)
console.log(b)
console.log(c)
}
});
check_id = setTimeout(progressCheck, 1000);
return ajax;
}
// set progress checking function to call every second
var check_id = setTimeout(progressCheck, 1000);
function clearCheck(){
try {
clearTimeout(check_id);
} catch (e) {
alert("There was an error clearing the check: " + e);
return false;
}
return true;
}