javascript - unable to send ajax request on php -
I am using an AJAX request to send to php. In the form method, I am using the following code.
rohit1.php
& lt; Form action = "index1.php" onsubmit = "callfunc ()" & gt; & Lt; Span id = "raj" & gt; & Lt; / Span & gt; & Lt; Input type = "submit" value = "submit" & gt; & Lt; / Div & gt; & Lt; / Form & gt; In JavaScript, I am using: callfun.js
function callfunc () {var http = new XMLHttpRequest (); Var Name = Prompt ('Enter the name of the form'); Var Name = "Rohit"; Var url = "index1.php"; Var s = document.getElementById ('raj'). InnerHTML; Warning (http); Http.open ("POST", "index1.php? Name =" + name, true); Http.onreadystatechange = function {if (http.readyState == 4 & amp; http.status == 200} {}} http.send ();} When I Function, then submitting it is redirecting to index.php? Label = on the name of index.php? Name = what should I do for it ???
just try to add return false at the end of the callfunk () function. Will stop the default event and will not function as a standard form. < / Div>
Comments
Post a Comment