PHP Ajax PHP Ajax
function $ (ID) {return document.getElementById (ID);} function AddComment () {var url = "14-6.php", var status = document.getElementById ("divmsg"); status.value= "Submitting" "; var param = "Name=" +$ ("name"). Value+ "email=" +$ ("email"). value+ "comment=" +$ ("comment"). value;xmlhttp_ Request.onreadystatechange = function () {if (xmlhttp_request.readystate==4 && xmlhttp_request.status = = 200) {/ /corresponding full display of Information alert (xmlhttp_request.responsetext); if (Xmlhttp_request.responsetext = = "1") {Status.value = "published successfully!! "; $ (" name "). value=" "; $ (" email "). value=" "; $ (" comment "). value=" ";} Else{status.value = "Publishing failed!" Please re-publish! ";}}} Xmlhttp_request.open ("POST", url,true); Xmlhttp_request.setrequestheader ("Content-type", "application/ X-www-form-urlencoded ");//Set Header information Xmlhttp_request.send (param);}
I don't know why, this responsetext returns a large HTML code.
Reply to discussion (solution)
Above is what alert (xmlhttp_request.responsetext) returns.
Are you asking for the current page?
Isn't that the wrong message?
14-6.php the 4th Line of $_post[' email ' is not defined
var param = "Name=" +$ ("name"). Value+ "email=" +$ ("email"). value+ "comment=" +$ ("comment"). value;
Should write
var param = "Name=" +$ ("name"). Value+ "&email=" +$ ("email"). value+ "&comment=" +$ ("comment"). value;
My is from an HTML file to the PHP file.
The HTML code is below. My total is only two files, an HTML file, a PHP file
Insert Title here
The problem has been solved, is the moderator said the error. When committing three different variables between &, because just touch Ajax, so the post submission is not very understanding.