AJAX POST and PHP -


I have an AJAX script that sends a post request to PHP with some values. When I try to get value in PHP, I can not get anything.

AJX script is

  xmlhttp.open ("POST", "handle_data.php", true); Xmlhttp.setRequestHeader ("content type", "text / plain"); Var CMDStr = "CMD1 = Command and CMD2 = Command2"; Xmlhttp.send (cmdStr); Warning (xmlhttp.responseText);  

PHP script is

   

Output is just a plain empty warning box. Is there any mistake in the code?

  xmlhttp.onreadystatechange = function (if {(This.readyState == 4 & amp; ; Amp; this.status == 200) {If (this.responseText! = Null) {Warning (this.responseText); }}; }  

You have to wait for the data to be used to represent the callback to use onreadystatechange .


Comments