title: Loads external php file with javascript src
body: <p>I'm currently using below method to call an external php file with some variables using javascript</p>
  
  <pre><code>&lt;script src="http://www.domain.com/function.php?param=A" type="text/javascript"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>And the code in the function.php file will return data in Javascript format, something like</p>
  
  <pre><code>&lt;?php Header("content-type: application/x-javascript");
  $p = $_GET['param'];
  
  $r = mt_rand(0, 10);
  echo "document.write('" . $p . $r . "');";
  ?&gt;
  </code></pre>
  
  <p>This is just a simple example. My problem is on Google Chrome (v19), if the page had not finished loaded, the random number will not be random when I keep refreshing. It will become truly random only when I hit the refresh button AFTER the page finished load. Why is this happen and how can I solve it?</p>
  
  <p>I tested on Firefox 12 and IE8, even if I refresh the page before it finished load, the random number will always be regenerated.</p>