Note that there are some explanatory texts on larger screens.

plurals
  1. POAjax post displaying an inadequate message
    text
    copied!<p>I am new to AJAX methods. I want to post some infos that are processes by a php page, call it page.php</p> <p>In my html page, I have put this code : </p> <pre><code>&lt;script type="text/javascript" charset="utf-8"&gt; //I have put the function getXMLHttpRequest() on a separate js file function getXMLHttpRequest() { var xhr = null; if (window.XMLHttpRequest || window.ActiveXObject) { if (window.ActiveXObject) { try { xhr = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { xhr = new ActiveXObject("Microsoft.XMLHTTP"); } } else { xhr = new XMLHttpRequest(); } } else { alert("Votre navigateur ne supporte pas l'objet XMLHTTPRequest..."); return null; } return xhr; } function request(callback) { var xhr = getXMLHttpRequest(); xhr.onreadystatechange = function() { if (xhr.readyState == 4 &amp;&amp; (xhr.status == 200 || xhr.status == 0)) { callback(xhr.responseText); } }; xhr.open("POST", "page.php", true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.send("name=proposition"); } function postData(Data) { alert(Data); } &lt;/script&gt; &lt;button onclick="request(postData);"&gt;...&lt;/button&gt; </code></pre> <p>In page.php, I have a method </p> <pre><code>protected function comment(){ //some code processing the posted infos (that works fine)... //to debug, I have put a echo('Hello world'); } </code></pre> <p>The fact is I don't get any 'Hello world' but a huge alert message with all my webpage code displayed.</p> <p>Anyone has an idea ? </p> <p>Best, Newben</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload