title: AJAX XMLHttpRequest to display a file doesnt work with pagination
body: <p>I'm using this script to load my serverlist php file however it doesn't work with pagination it just refreshes the page and loads the same results from the first page. I'm not asking for someone to write out the fix for me but if someone could help point me in the right direction i would be grateful</p>
  <pre><code>&lt;pre&gt;
    &lt;script type=&quot;text/javascript&quot;&gt;
      function refreshData(){
        var display = document.getElementById(&quot;servers&quot;);
        var xmlhttp = new XMLHttpRequest();
        xmlhttp.open(&quot;GET&quot;, &quot;query/Examples/serverlist.php&quot;);
        xmlhttp.setRequestHeader(&quot;Content-Type&quot;, &quot;application/x-www-form-urlencoded&quot;);
        xmlhttp.send();
        xmlhttp.onreadystatechange = function() {
          if (this.readyState === 4 &amp;&amp; this.status === 200) {
            display.innerHTML = this.responseText;
          } else {
            display.innerHTML = &quot;Loading...&quot;;
          };
        }
      }
    &lt;/script&gt;
              
    &lt;div id=&quot;servers&quot; /&gt;&lt;img src=&quot;includes/IMG/loading.gif&quot;/&gt;
  &lt;/div&gt;
  &lt;/pre&gt;
  </code></pre>
  <p>This is my serverlist.php file</p>
  <pre><code>&lt;pre&gt;
  &lt;?php
  require_once('../../includes/connect.php');
  $sql= &quot;SELECT * FROM servers ORDER BY votes DESC&quot;;
  $result = $db-&gt;query($sql); 
  $row = $result-&gt;fetch(PDO::FETCH_ASSOC);
  
      require __DIR__ . '/../SourceQuery/bootstrap.php';
  
      use xPaw\SourceQuery\SourceQuery;
      $perPage = 5;
  
      // Calculate Total pages
      $stmt = $db-&gt;query('SELECT * FROM servers');
      $total_results = $stmt-&gt;fetchColumn();
      $total_pages = ceil($total_results / $perPage);
  
      // Current page
      $page = isset($_GET['page']) ? $_GET['page'] : 1;
      $starting_limit = ($page - 1) * $perPage;
      if($page &lt; 1) { 
      header (&quot;location: index.php&quot;);
      }
  
      // Query to fetch servers
      $q = &quot;SELECT * FROM servers ORDER BY votes DESC LIMIT :start, :per_page&quot;;
      $query = $db-&gt;prepare($q);
      $query-&gt;bindParam(':start', $starting_limit, PDO::PARAM_INT);
      $query-&gt;bindParam(':per_page',$perPage, PDO::PARAM_INT);
      $query-&gt;execute();
  
      // Fetch all servers for current page
          $result = $query-&gt;fetchAll(PDO::FETCH_ASSOC);;
      ?&gt;
      &lt;div class=&quot;table-responsive&quot;&gt;
    &lt;table class=&quot;table table-striped table-hover table-borderless &quot;&gt;
      &lt;thead&gt;
        &lt;tr&gt;
          &lt;th scope=&quot;col&quot;&gt;#&lt;/th&gt;
          &lt;th scope=&quot;col&quot;&gt;Server&lt;/th&gt;
          &lt;th scope=&quot;col&quot;&gt;IP&lt;/th&gt;
          &lt;th scope=&quot;col&quot;&gt;Players&lt;/th&gt;
          &lt;th scope=&quot;col&quot;&gt;Type&lt;/th&gt;
          &lt;th scope=&quot;col&quot;&gt;Votes&lt;/th&gt;
        &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
      
      &lt;?php
      $i = $page * $perPage -4;
  foreach ($result as $row) {
  $focus = $row['focus'];
  $type = $row['type'];
      
      $Timer = microtime( true );
      
      $Query = new SourceQuery( );
      
      $Info    = [];
      $Players = [];
      $Exception = null;
      
      try
      {
          $Query-&gt;Connect( $row['ip'], $row['qport'], 3, SourceQuery::SOURCE );
          //$Query-&gt;SetUseOldGetChallengeMethod( true ); // Use this when players/rules retrieval fails on games like Starbound
          
          $Info    = $Query-&gt;GetInfo( );
          $Players = $Query-&gt;GetPlayers( );
      }
      catch( Exception $e )
      {
          $Exception = $e;
      }
      finally
      {
          $Query-&gt;Disconnect( );
      }
      
      $Timer = number_format( microtime( true ) - $Timer, 4, '.', '' );
   
  ?&gt;
  
  &lt;?php if( !empty( $Info ) ): ?&gt;
  
        &lt;tr&gt;
        &lt;?php if($i == 1) { ?&gt;
          &lt;tr class=&quot;table-warning&quot;&gt;
        &lt;?php }else{ ?&gt;
         &lt;tr&gt;
        &lt;?php } ?&gt;
        &lt;th scope=&quot;row&quot;&gt;
          &lt;?php echo $i; ?&gt;&lt;/th&gt;
          &lt;td&gt;&lt;?php echo $Info['HostName'];  ?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $row['ip']; ?&gt;:&lt;?php echo $row['port']; ?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $Info['Players']; ?&gt;/&lt;?php echo $Info['MaxPlayers']; ?&gt;&lt;/td&gt;
          &lt;td&gt;
  &lt;?php 
  switch ($focus) {
    case &quot;1&quot;:
      echo &quot;Crafting&quot;;
      break;
    case &quot;2&quot;:
      echo &quot;Roleplay&quot;;
      break;
    case &quot;3&quot;:
      echo &quot;PVP&quot;;
      break;
    case &quot;4&quot;:
      echo &quot;PVE&quot;;
      break;
  }
  ?&gt;
  |&lt;?php 
  switch ($type) {
    case &quot;0&quot;:
      echo &quot;Vanilla&quot;;
      break;
    case &quot;1&quot;:
      echo &quot;Modded&quot;;
      break;
  }
  ?&gt;
  &lt;/td&gt;
          &lt;td&gt;
          
           &lt;a href=&quot;vote.php?id=&lt;?php echo $row['id']; ?&gt;&quot;&gt;
  &lt;div class=&quot;btn-group&quot; role=&quot;group&quot; aria-label=&quot;Basic outlined example&quot;&gt;
    &lt;button type=&quot;button&quot; class=&quot;btn btn-outline-success&quot;&gt;&lt;?php echo $row['votes']; ?&gt;&lt;/button&gt;
   &lt;button type=&quot;button&quot; class=&quot;btn btn-success&quot;&gt;Vote&lt;/button&gt;
  &lt;/div&gt;
  &lt;/a&gt;
          
          &lt;/td&gt;
        &lt;/tr&gt;
          
  
  &lt;?php else: ?&gt;
        &lt;tr class=&quot;table-danger&quot;&gt;
          &lt;th scope=&quot;row&quot;&gt;&lt;?php echo $i; ?&gt;&lt;/th&gt;
          &lt;td&gt;&lt;?php echo $row['servername'];  ?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $row['ip']; ?&gt;:&lt;?php echo $row['port']; ?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $row['maxplayers']; ?&gt;&lt;/td&gt;
          &lt;td&gt;
          &lt;?php 
  switch ($focus) {
    case &quot;1&quot;:
      echo &quot;Crafting&quot;;
      break;
    case &quot;2&quot;:
      echo &quot;Roleplay&quot;;
      break;
    case &quot;3&quot;:
      echo &quot;PVP&quot;;
      break;
    case &quot;4&quot;:
      echo &quot;PVE&quot;;
      break;
  }
  ?&gt;
  |&lt;?php 
  switch ($type) {
    case &quot;0&quot;:
      echo &quot;Vanilla&quot;;
      break;
    case &quot;1&quot;:
      echo &quot;Modded&quot;;
      break;
  }
  ?&gt;
          &lt;/td&gt;
          &lt;td class=&quot;table-danger&quot;&gt;
          
           &lt;a href=&quot;vote.php?id=&lt;?php echo $row['id']; ?&gt;&quot;&gt;
  &lt;div class=&quot;btn-group&quot; role=&quot;group&quot; aria-label=&quot;Basic outlined example&quot;&gt;
    &lt;button type=&quot;button&quot; class=&quot;btn btn-outline-success&quot;&gt;&lt;?php echo $row['votes']; ?&gt;&lt;/button&gt;
   &lt;button type=&quot;button&quot; class=&quot;btn btn-success&quot;&gt;Vote&lt;/button&gt;
  &lt;/div&gt;
  &lt;/a&gt;
          
          &lt;/td&gt;
        &lt;/tr&gt;
  
                      
  &lt;?php endif; ?&gt;
                  
  &lt;?php $i++; } ?&gt;    
      &lt;/tbody&gt;
  
    &lt;/table&gt;
    &lt;/div&gt;
   &lt;?php for ($page = 1; $page &lt;= $total_pages ; $page++):?&gt;
          &lt;a href='&lt;?php echo &quot;?page=$page&quot;; ?&gt;' class=&quot;links&quot;&gt;
              &lt;?php  echo $page; ?&gt;
          &lt;/a&gt;
      &lt;?php endfor; ?&gt;   
  &lt;/div&gt;  
  &lt;/pre&gt;
  </code></pre>