62
rated 0 times
[
63]
[
1]
/ answers: 1 / hits: 32327
/ 8 Years ago, mon, february 1, 2016, 12:00:00
Like i explain here , i can't use window.setTimeout() anymore and any window classical functions like clearInterval etc ...); but i need calling a JS block code as an async one.
That's why i used XHR request.
What is the best way to implement a smart alternative to window.setTimeout() with XHR ?
// Not working :(
setTimeout(function(){
document.getElementById(messageTimer).innerHTML = Happy New Year ! (old version);
}, 10);
// with or without jQuery - but XHR
jQuery.ajax({
url: /local/url/easy,
success: function(html, textStatus, jqXHR) {
// a loop ?
// timeout done ?
document.getElementById(messageTimer).innerHTML = Happy New Year ! (working version)
}});
My fiddle test : https://jsfiddle.net/mlefree/xzh3w2we/
Tks
More From » xmlhttprequest