title: How to load data fetched via ajax faster?
body: <p>Currently data is fetched as an array form PHP script. SO I find that for 40 set of data it take about 20 seconds to load. I guess it's because ajax has to wait till until all the results gathered. If the data set increased to hundreds, I think it's gonna slow sown a lot. </p>
  
  <p>So I did some research on how to decrease the loading time thus come across parallel ajax request. I think it would be helpful, for multiple requests.For single request but hundreds and thousands of data fetched, is there a way to increase the speed?</p>
  
  <p>JS :</p>
  
  <pre><code>$(function() {
      $.ajax({
          dataType: "json",
          url: 'showAllTutor.php',
          success: function(data) {
              console.log(data.length);
              var j=0;
              for (i = 0; i &lt; data.length; i++) {
                  j++;
                  console.log(data[i].name);
              }
          }
      });
  });
  </code></pre>
  
  <p>PHP :</p>
  
  <pre><code> $sql="SELECT * FROM userinfo,posts WHERE userinfo.UUID = posts.UUID AND posts.p_id &gt; '$last_msg_id'";
          $stmt =connection::$pdo-&gt;prepare($sql);
          $stmt-&gt;execute();
          $json=array();
  
          while($row = $stmt-&gt;fetch()) {
               $total = $row['reviewPlus']+ $row['reviewNeg'];
               array_push($json,array("name"=&gt;$row['name'],"subject"=&gt;$row['subname'],"subid"=&gt;$row['subID'],"rate"=&gt;$row['pricing'],"dateposted"=&gt;$row['datePosted'],"location"=&gt;$row['location'],"contact"=&gt;$row['phone'],"morning"=&gt;$row['morning'],"afternoon"=&gt;$row['afternoon'],"evening"=&gt;$row['evening'],"postId"=&gt;$row['p_id'],"total"=&gt;$total,"plus"=&gt;$row['reviewPlus'],"user"=&gt;$row['UUID']));                
          }       
      }       
      echo json_encode($json);
  </code></pre>