javascript - to use changed value in setTimeout() function -


    //to make ajax call server get list data     function makeajaxcall()     {         loginsuccess =0;          //to make ajax call server supported banks details         var xmlhttp;          // code ie7+, firefox, chrome, opera, safari         xmlhttp=new xmlhttprequest();          xmlhttp.onreadystatechange=function()         {             alert('here'+xmlhttp.readystate+'stat='+xmlhttp.status)             if( xmlhttp.readystate==4 && xmlhttp.status==200 )             {                 alert(xmlhttp.responsetext)                 if(xmlhttp.responsetext != '' )                 {                     loginsuccess =1;                     renderresponse(xmlhttp.responsetext);                 }                 //else                 {                  }             }             //else if(  )         }           var params = "flaglogin="+flaglogin+"&listname="+selectedlist+formdata+loginpara;          //var url = serverurl;         var url = 'https://blah.com';          //alert('param='+params)         xmlhttp.open("post",url,true);         xmlhttp.setrequestheader("content-type","application/x-www-form-urlencoded");         xmlhttp.send(params);          settimeout('showloginagain()',15000);          // return         return;     } 

in above code , making ajax calls , want use value of global variable loginsuccess when showloginagain() gets called - 15 seconds after settimeout() gets called.

how make second ajax call change value of variable time showloginagain() first ajax call invoked?


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -