Example Description:
| The code is as follows |
Copy Code |
| <script> $ (document). Ready (function () { $ (". Ajax_btn"). Click (function () { $.post ("ajax.php", {name:$ ("#name"). Val ()},//Gets the value of the class name "name" and asynchronously passes the value with name function (data) {//data is a return value, function returns value processing $ ("#content"). Val (data), after you get the back value, fill it in a text box with the class name "content" }); }) }) </script> <form id= "Ajaxform" name= "Ajaxform" method= "post" action= "action.php" > <p> Email<input type= "text" name= "name" id= "name"/>
</p> <p> Address<input type= "text" name= "Address" id= "Address"/> </p> <p id= "MSG" ></p> <p> <input name= "Submit" type= "button" value= "Submit" onclick= "return Checkemail ()"/> </p> </form> Return content after post <div id= "Content" ></div> |
ajax.php Code:
| The code is as follows |
Copy Code |
<?php $name =$_post["name"]; if ($name = = "Netxu") { echo "I'm sorry," $name. " Data exists "; } else{ echo "Congratulations," $name. " can use "; } ?> |
About Post Brief introduction
Function prototypes: $.post (URL, params, callback)
URL is the address of the submission, eg: "Sample.ashx"
Params is a parameter, eg: {name: "XXX", ID: "001"}
Callback is a callback function, Eg:function (msg) {alert (msg);