title: how to use a randomized TOKEN to reload PHP script with AJAX, url is being cached?
body: <p>I have this AJAX call I'm making. How can I make this JQuery refresh/reload the script that is being called and execute the AJAX call afterwards. I want to use this in case the user re-clicks the same button again and show new data.</p>
  
  <p><strong>Problem:</strong></p>
  
  <p>How do I include a token? My show_aht.php is being cached</p>
  
  <p>When aht_button is clicked it returns data, but if I refresh the page and/or I reclick the button it will still show me the old data or do nothing at all. I have to manually refresh my "show_aht.php" on my browser and then click on "aht_button" so I can display the new data being retrieve from "show_aht.php". </p>
  
  <p>I did not want to post my PHP code because its a lot of stuff.. maybe someone can find the problem because I have no clue. Not sure if we can reload a PHP script by itself? I've put only the important stuff. </p>
  
  <p>thanks in advance!</p>
  
  <p>JS:</p>
  
  <pre><code>&lt;div id="aht"&gt;
      &lt;button id="aht_button"&gt;AHT&lt;/button&gt;    
  &lt;/div&gt;
  
  &lt;script type="text/javascript"&gt;
          $(document).ready(function() {
                  $('#aht').click(function(){
                      $.ajax({
                      type:"GET",
                      url : "show_aht.php", //use a token here??
                      data:{ } ,
                      dataType: 'json',
                      success : function(data){
                          //get the MIN value from the array
                              var min = data.reduce(function(prev, curr) {
                                  return isNaN(+curr['aht_value']) || prev &lt; +curr['aht_value'] ? prev : +curr['aht_value'];
                              }, 1000000);
  
                              alert("min:" + min); 
                              //get the MAX value from the array
                              var max = data.reduce(function(prev, curr) {
                                return isNaN(+curr['aht_value']) || prev &gt; +curr['aht_value'] ? prev : +curr['aht_value'];
                              }, -1000000); 
  
                              alert("max:" + max);
                              //function for calculation of background color depending on aht_value               
                              function conv(x){
                                  return Math.floor((x - min) / (max - min) * 255);
                              }
  
                              //function for background color, if NA then show white background, either show from green to red
                              function colorMe(v){
                                return v == 'NA' ? "#FFF" : "rgb(" + conv(v) + "," + (255-conv(v)) + ",0)";
                              }
  
                          //going through all DIVs only once with this loop
                          for(var i = 0; i &lt; data.length; i++) { // loop over results
                          var divForResult = $('#desk_' + data[i]['station']); // look for div for this object
                          if(divForResult.length) { // if a div was found
                              divForResult.html(data[i]['aht_value']).css("background-color", colorMe(data[i]['aht_value']));
                          }//end if
                          }//end for  
                      }//end success
                  });//end ajax   
                });//end click
              });//end rdy
          &lt;/script&gt;
  </code></pre>
  
  <p>PHP:</p>
  
  <pre><code>include 'db_conn_retca2003.php';
  include 'db_conn_retca2001.php';
  header('Content-type: application/json');
  
      /****************************************************
      matching USER array and MEMO array 
      for matching username values
      /****************************************************/
      $result = array();
      foreach ($memo as $username =&gt; $memodata) {
      if (in_array($username, array_keys($user))) {
      // Match username against the keys of $user (the usernames) 
      $userdata = $user[$username];
      //if AHT is null give N/A as value
      if (is_null($memodata['aht_value'])) {
          $result[] = array( 'username'  =&gt; $userdata['username'],
                                               'aht_value' =&gt; 'NA',
                                               'station'  =&gt; $userdata['station']
                                              );
      }//end inner if 
      //else give the actual value of AHT without the decimals
      else {
          $result[] = array( 'username'  =&gt; $userdata['username'],
                                               'aht_value' =&gt; substr($memodata['aht_value'],0,-3),
                                               'station'   =&gt; $userdata['station']
                                          );
      }//end else
      }//end outer if
      }//end for
    echo json_encode($result);
  ?&gt;
  </code></pre>