PHP, AJAX and HTML, function never called
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/11518422/how-to-call-a-php-function-from-a-form-button">how to call a PHP function from a form button</a>  </p>
</blockquote>



<p>I've got a button like this:</p>

<pre><code>&lt;form method="post" id="submit" action="script/gen.php"&gt;
    &lt;input type="button" onClick="getKey()" value="Generate key"/&gt;
</code></pre>

<p>This calls a javascript in the same file that looks like this:</p>

<pre><code>&lt;script type="text/javascript"&gt;
        function getKey() {
            if (window.XMLHttpRequest) {
                xmlhttp=new XMLHttpRequest();

        }
        else {
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }

        xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200) {
            document.getElementById("innhold").innerHTML=xmlhttp.responseText;
        }
    }
        xmlhttp.open("GET","script/gen.php?returnKey",true);
        xmlhttp.send();
    }
&lt;/script&gt;
</code></pre>

<p>I know that this javascript is beeing called, by adding an <code>alert()</code> several places inside the script. The problem occurs when I try to do an <code>isset</code> in my php code:</p>

<pre><code>else if(isset($_GET['returnKey'])) {
returnKey();
}
</code></pre>

<p>This function is never beeing called, even if I add a <code>echo</code> before I do the function call <code>returnKey()</code></p>

<p>Can anyone see where the problem is? </p>

<p><strong>EDIT</strong></p>

<p>This is what the console has to tell me, from chrome:</p>

<pre><code>XMLHttpRequest cannot load file:///C:/wamp/www/Webpanel/script/gen.php?returnKey. Cross    origin requests are only supported for HTTP.
Uncaught Error: NETWORK_ERR: XMLHttpRequest Exception 101 index.html:37
getKey index.html:3
</code></pre>

<p><strong>EDIT 2</strong></p>

<p>Holy moses, I figured it out. Had to type in localhost/Webpanel in my browser. Its been a long day, so I not quite clear..</p>
