Note that there are some explanatory texts on larger screens.

plurals
  1. POAJAX post method: Variables are not passed to target php
    text
    copied!<p>I am trying to send two pieces of info to a php. 1-) tent = zuzu 2-) zart = gagi</p> <p>target php simply echoes what I send so that I can check if it's working. This is the javascript:</p> <pre><code> function boka () { var mesparam = "tent=zuzu&amp;zart=gagi"; 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("response").innerHTML=xmlhttp.responseText;} } xmlhttp.open("POST","/mysite/oxifa/oxifat.php?tent=zuzu&amp;zart=gagi",true); //xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); //xmlhttp.setRequestHeader("Content-length", mesparam.length); //xmlHttp.setRequestHeader("Connection", "close"); xmlhttp.send(mesparam); } </code></pre> <p>This is oxifat.php that recieves the request:</p> <pre><code> &lt;?php echo " sign1 &lt;br&gt;"; echo next($_POST); echo next($_POST); echo next($_POST); echo next($_POST); echo next($_POST); echo $_POST['tent']; echo $_POST['zart']; echo $_REQUEST['tent']; echo $_REQUEST['zart']; echo "&lt;br&gt; sign2"; ?&gt; </code></pre> <p>As you can see I've included all sorts of things to echo out whatever is in $_POST but apparently there is nothing there and this is the response I get:</p> <p>sign1</p> <p>Notice: Undefined index: tent in C:\wamp\www\mysite\oxifa/oxifat.php on line 16</p> <p>Notice: Undefined index: zart in C:\wamp\www\mysite\oxifa/oxifat.php on line 17</p> <p>Notice: Undefined index: tent in C:\wamp\www\mysite\oxifa/oxifat.php on line 18</p> <p>Notice: Undefined index: zart in C:\wamp\www\mysite\oxifa/oxifat.php on line 19</p> <p>sign2 </p> <p>three lines about the "setRequestHeader" are in comment status. If I include them, I don't even get sign1. No response. What I figure out from this is everything is OK but I don't seem to understand how to use the post method to pass data to php. How do I do this? I have read everything on the net. I only do not know what "setRequestHeader" is for. One more thing: If I put ?tent=zuzu&amp;zart=gagi at the end of target URL, $_REQUEST thing works. But that's GET and not what I'm trying to do. What is the $_POST's deal? </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