Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- This javascript setTimeout interacts with ajax requests in a really weird way
- function progres_import() {
- //if(import_status != 'finalizat') {
- alert("progres_import");
- setTimeout(function() { return update_progres_import(); }, 2000);
- setTimeout(function() { return update_progres_import(); }, 4000);
- setTimeout(function() { return update_progres_import(); }, 6000);
- setTimeout(function() { return update_progres_import(); }, 8000);
- //setTimeout(function() { progres_import(); }, 400);
- //}
- //else {
- //}
- }
- var xmlhttp_import_progres;
- function update_progres_import() {
- xmlhttp_import_progres=GetXMLHttpObject();
- if (xmlhttp_import_progres==null) {
- alert ("Browser does not support HTTP Request (xmlhttp_import_progres)");
- return;
- }
- var url="crm/ferestre/import_progres.php";
- url=url+"?sid="+Math.random();
- xmlhttp_import_progres.onreadystatechange=function() {
- if (xmlhttp_import_progres.readyState == 4) {
- progres_resp = xmlhttp_import_progres.responseText;
- progres = progres_resp.split('_');
- import_nrc = progres[0];
- import_nrt = progres[1];
- import_status = progres[2];
- mesaj = 'Progres import: ' + import_nrc + ' / ' + import_nrt;
- //document.getElementById("corp_import_mesaj").innerHTML = mesaj;
- alert(progres_resp);
- }
- };
- xmlhttp_import_progres.open("POST",url,true);
- xmlhttp_import_progres.send(null);
- }
- function progres_import() {
- //if(import_status != 'finalizat') {
- alert("progres_import");
- setTimeout(function() { return update_progres_import(0); }, 2000);
- setTimeout(function() { return update_progres_import(1); }, 4000);
- setTimeout(function() { return update_progres_import(2); }, 6000);
- setTimeout(function() { return update_progres_import(3); }, 8000);
- //setTimeout(function() { progres_import(); }, 400);
- //}
- //else {
- //}
- }
- var xmlhttp_import_progres = [];
- function update_progres_import(i) {
- xmlhttp_import_progres[i]= GetXMLHttpObject();
- if (xmlhttp_import_progres[i]==null) {
- alert ("Browser does not support HTTP Request (xmlhttp_import_progres)");
- return;
- }
- var url="crm/ferestre/import_progres.php";
- url=url+"?sid="+Math.random();
- xmlhttp_import_progres[i].onreadystatechange=function() {
- if (xmlhttp_import_progres[i].readyState == 4) {
- progres_resp = xmlhttp_import_progres[i].responseText;
- progres = progres_resp.split('_');
- import_nrc = progres[0];
- import_nrt = progres[1];
- import_status = progres[2];
- mesaj = 'Progres import: ' + import_nrc + ' / ' + import_nrt;
- //document.getElementById("corp_import_mesaj").innerHTML = mesaj;
- alert(progres_resp);
- }
- };
- xmlhttp_import_progres[i].open("POST",url,true);
- xmlhttp_import_progres[i].send(null);
- }
Add Comment
Please, Sign In to add comment