title: jQuery ajax call to update progress bar
body: <p>I'm currently using a ajax call to start a big process on mysql !. during this process, I save a percent value in a database.</p>
  
  <p>After this Ajax call to the PHP Script I start another ajax call to another php script that reads this value from database.</p>
  
  <p>All calls are async true!.</p>
  
  <p>The problem... second ajax call seems to start just after the first one finished.</p>
  
  <pre><code>function Get815(){
     $('#Pgbar').window('open');
     $('#p').progressbar('setValue', 0);
    getStatus();
    myVar= setInterval('getStatus()', 3000);
    startProcess();
  
  }
  
  
  
  
  function getStatus() {
      $.ajax(
              {
                  type: 'GET',
                  url: "lib/get_percent.php",
                  async: true,
                  success:
                      function (jdatos) {
                          data = eval('('+jdatos+')');
                          if(data[0]['result']===true){
                              if(data[0]['data']&lt;parseInt('100')){
                                  $('#p').progressbar('setValue', data[0]['data']);
                                  return true;
                              }
                          }else{
                              alert('dio false');
                          };
  
                      }
  
  
              });
  }
  
  
  function startProcess() {
      $.ajax(
              {
                  type: 'GET',
                  url: "815/815.php",
                  async: true,
                  success: function(jdatos) {
                    data = eval('('+jdatos+')');
                    if(data[0]['result']===true){
                       alert('Finished');
                    }else{
                       alert('Error');
  
                    }
                  }
              });
  }
  </code></pre>
  
  <p>Here part of Big Process Script
      ..
      ..
      logger('counter ' .$nPercent . ' nCounter ' . $nCounter . ' nTotal ' . $nTotal);</p>
  
  <pre><code>$stmt = $db-&gt;stmt_init();
  $stmt-&gt;prepare("update `percent` set value=?");
  if($stmt===false){ logger('SQL Prepare Error');}
  $rc=$stmt-&gt;bind_param('s', $nPercent );
  if($rc===false){ logger('SQL Bind Error');}
  if($stmt-&gt;execute()==false){ logger('SQL Execute Error ' . $stmt-&gt;error); };
  $stmt-&gt;close();  
  ..
  ..
  ..
  $db-&gt;close();
  $aReturn[]= array('result'=&gt;true );
  exit(json_encode($aReturn));  
  </code></pre>
  
  <p>Logger function save to a log database... in that way I can see in real time whats is going on during the process.</p>
  
  <p>now part of get_percent.php</p>
  
  <pre><code>..
  ..
  $cSelectNodes="select value from percent";
  if(!$result1 = $db-&gt;query($cSelectNodes))
  {
      debug('There was an error running the query [' . $db-&gt;error . ']');
      $aReturn[]= array('result'=&gt;false );
      exit(json_encode($aReturn)); 
  }
  while($row = $result1-&gt;fetch_assoc()) {
      $nPercent="";
      $nPercent=$row['value'];
  }
  $result1-&gt;close();
  $db-&gt;close();
  
  $aReturn[]= array('result'=&gt;true , 'data'=&gt; $nPercent);
  exit(json_encode($aReturn));
  </code></pre>
  
  <p>Just after 815.php has finished , then the progress bar get reflected but with the last percent taken from database.</p>
  
  <p>does anyone knows why this is happening?</p>
  
  <p>Kind Regards, </p>