Use JQuery to submit the form without refreshing the following code
<form id= "Formupdate" action= "/updateinfo?fun=update" method= "post" target= "_self" >
<input id= "Id_user" name= "Id_user" type= "hidden" value= "0001" >
<input name= "button" type= "Submit" value= "OK" onclick= "submittheform ()"/>
</form>
<script lang= "JScript" >
function Submittheform ()
{
Get form by ID of form
var $form = $ (' #formUpdate '); Is critical
Get the form's submit path
url = $form. attr (' action '); Get the submit path to the form and assign it to the URL
Submitted as post, callback function functions return data
var i = $.post (URL, $form. Serialize (), function (data)
{
Display return information
alert (data);
});
Another form jquery.post (URL, $form. Serialize ()); can also
}
</script>
JQuery Official website http://jquery.com/ Examples: example:request the test.php page, but ignore the return results.
$.post ("test.php");
example:request the test.php page and send some additional data along (while still ignoring the return results).
$.post ("test.php", {name: "John", Time: "2pm"});
example:pass Arrays of data to the server (while still ignoring the return results).
$.post ("test.php", {' choices[] ': ["Jon", "Susan"]});
example:send form data using AJAX requests
$.post ("test.php", $ ("#testform"). Serialize ());
Example:alert out of the results from requesting test.php (HTML or XML, depending on what is returned).
$.post ("test.php", function (data) {
alert ("Data Loaded:" + data);
});
Example:alert out the results from requesting test.php with a additional payload of data (HTML or XML, depending on What was returned).
$.post ("test.php", {name: "John", Time: "2pm"},
function (data) {
alert ("Data Loaded:" + data);
});
example:gets The test.php page content, store it in a Xmlhttpresponse object and applies the process () JavaScript fun Ction.
$.post ("test.php", {name: "John", Time: "2pm"},
function (data) {
process (data);
},
"xml"
);
example:posts to the test.php page and gets contents which has been in JSON format (returned Echo <?php De (Array ("name" => "John", "Time" => "2pm")),?>).
$.post ("test.php", {"Func": "Getnameandtime"},
function (data) {
console.log (data.name);//John
con Sole.log (Data.time); 2pm
}, "json");
example:post a form using AJAX and put results in a div
<! DOCTYPE html>
<script src= "Http://code.jquery.com/jquery-latest.js" ></script>
<body>
<form action= "/" id= "Searchform" >
<input type= "text" name= "s" placeholder= "Search ..."/>
<input type= "Submit" value= "Search"/>
</form>
<!--The result of the search is rendered inside this div-->
<div id= "Result" ></div>
<script>
/* Attach a submit handler to the form * * *
$ ("#searchForm"). Submit (Function (event) {
/* Stop form from submitting normally * *
Event.preventdefault ();
/* Get some values from elements on the page: * *
var $form = $ (this),
term = $form. Find (' Input[name= "s"] "). Val (),
url = $form. attr (' action ');
/* Send the data using post and put the results in a div * *
$.post (URL, {s:term}, function (data)
{
var content = $ (data). Find (' #content ');
$ ("#result"). Empty (). append (content);
}
);
});
</script>
</body>