Run php script every x mins using ajax request
<p>got this file 'functions.php':</p>

<pre><code>&lt;?php
function test ($url){
$starttime = microtime(true);
$valid = @fsockopen($url, 80, $errno, $errstr, 30);
$stoptime = microtime(true);
echo (round(($stoptime-$starttime)*1000)).' ms.';

if (!$valid) {
   echo "Status - Failure";
} else {
   echo "Status - Success";
}
}
    test('google.com');
?&gt;
</code></pre>

<p>I want to run it every 10seconds or so, i was told to use ajax request but i dont completely understand how it works. I tried creating a new file 'index.php', and then had this written in it:</p>

<pre><code>&lt;script&gt;
var milliSeconds = 10000; 
setInterval( function() {
    //Ajax request, i dont know how to write it
    xmlhttp.open("POST","functions.php",true);
    xmlhttp.send();
}, milliSeconds);
&lt;/script&gt;
</code></pre>

<p>I put both files into ftp but nothing happens, can someone help me write a propper ajax request?</p>

<p>Edit: eddited typo, still doesnt work tho</p>
