title: ajax calls not parallel
body: <p>i have two ajax calls. the first call is for read a file and save it into the DB (mysql) and at the bottom of a for loop they set an session variable of the "status" like the interval. 
  The second call return the session variable. </p>
  
  <p>this is my javascript code:</p>
  
  <pre><code> var interval = null;
  function test(data) {
      var i = 0;
      interval = setInterval(function () {
          $.ajax({
              url: '/admin/movies/progress',
              type: "GET",
              async: true,
              dataType: "text",
              success: function (data) {
                  console.log(data);
                  $('#saveFileProgressBar').width(data[0]);
              },
              error: function (XMLHttpRequest, textStatus, errorThrown) {
                  toastr.error('error progressbar', 'Download File');
              }
          });
          i++;
          if(i == 5){
              clearInterval(interval);
          }
      }, 500);
  
      $.ajax({
          url: '/admin/movies/1',
          type: "GET",
          async: true,
          dataType: "text",
          success: function (data) {
              console.log(data);
  
          },
          error: function (XMLHttpRequest, textStatus, errorThrown) {
              toastr.error('error', 'Download File');
          }
      });
  }
  </code></pre>
  
  <p>this is my laravel 5.4 code:</p>
  
  <pre><code>// Mapped to mysite.com/admin/movies/progress
  public function getProgress() {   
      return Response::json(array(Session::get('progress')));
  }
  
  // Mapped to mysite.com/admin/movies/1
  public function postGenerate() {
      // getting values from form (like $record_num)
      Session::put('progress', 0);
      Session::save(); // Remember to call save()
  
      for ($i = 1; $i &lt; 100; $i++) {
          sleep(1);
          Session::put('progress', $i);
          Session::save(); // Remember to call save()
      }
  
      return "done";
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/GxQob.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GxQob.png" alt="enter image description here"></a></p>
  
  <p>///////EDIT///////</p>
  
  <p>my new PHP code:</p>
  
  <pre><code>public function getProgress() {
      $rawData = file_get_contents('plugins/elFinder-2.1.25/files/data/progressFile.json');
      $cacheData = json_decode($rawData, true);
      return $cacheData;
  }
  
  public function postGenerate() {
      // getting values from form (like $record_num)
      for ($i = 0; $i &lt; 10; $i++) {
          $data['progress'] = $i;
          $fres = fopen('plugins/elFinder-2.1.25/files/data/progressFile.json', 'w');
          fwrite($fres, json_encode($data));
          fclose($fres);
          sleep(1);
      }
      return "true";
  }
  </code></pre>
  
  <p>my javascript code:</p>
  
  <pre><code> var interval = null;
  function test() {
      var i = 0;
      interval = setInterval(function () {
          $.ajax({
              url: '/admin/movies/progress',
              type: "GET",
              async: true,
              dataType: "text",
              success: function (data) {
                  console.log(data);
                  $('#saveFileProgressBar').width(data.progress);
              },
              error: function (XMLHttpRequest, textStatus, errorThrown) {
                  toastr.error('Es ist ein Fehler aufgetreten beim Auslesen der Datei', 'Download File');
              }
          });
          i++;
          if(i == 5){
              clearInterval(interval);
          }
      }, 500);
  
      $.ajax({
          url: '/admin/movies/1',
          type: "GET",
          async: true,
          dataType: "text",
          success: function (data) {
              console.log(data);
  
          },
          error: function (XMLHttpRequest, textStatus, errorThrown) {
              toastr.error('Es ist ein Fehler aufgetreten beim Auslesen der Datei', 'Download File');
          }
      });
  }
  </code></pre>