The example of this article describes the real time verification of JQUERY+AJAX implementation registration. Share to everyone for your reference, specific as follows:
When we register a user, will prompt that the user's information is available, this is the AJAX application, has seen this realization long ago, today looked again, to record down O (∩_∩) o ha!
First introduced under Ajax $.get, because $.post usage and $.get are not the same as the introduction:
This is a simple GET request function to replace the complex $.ajax. Callback functions can be invoked when the request succeeds. If you need to perform a function when an error occurs, use $.ajax.
Copy Code code as follows:
$ (selector). Get (Url,data,success (RESPONSE,STATUS,XHR), DataType)
Parameters |
Description |
Url |
Necessary. Specify which URL to send the request to. |
Data |
Optional. Specify the data to be sent to the server along with the request. |
Success (RESPONSE,STATUS,XHR) |
Optional. A function that is required to run when a request succeeds. Additional parameters:
- Response-Contains the result data from the request
- Status-Contains the state of the request
- XHR-Contains XMLHttpRequest objects
|
DataType |
Optional. Specify the data type of the expected server response. By default, JQuery will intelligently judge. Possible types:
- "XML"
- "HTML"
- "Text"
- "Script"
- "JSON"
- "Jsonp"
|
Request test.php Web page, ignore return value:
Copy Code code as follows:
More examples:
Example 1
Request test.php Web page, transfer 2 parameters, ignore return value:
Copy Code code as follows:
$.get ("test.php", {name: "John", Time: "2pm"});
Example 2
Displays the test.php return value (HTML or XML, depending on the return value):
$.get ("test.php", function (data) {
alert ("Data Loaded:" + data);
});
Example 3
Displays the test.cgi return value (HTML or XML, depending on the return value), and adds a set of request parameters:
$.get ("test.cgi", {name: "John", Time: "2pm"},
function (data) {
alert ("Data Loaded:" + data);
});
Post My Code below:
<?php
$link =mysql_connect ("localhost", "root", "");
mysql_select_db ("test");
mysql_query ("Set names UTF8");/
$sql = "SELECT * from user where user= '". $_get[' username ']. "'; /
$result =mysql_query ($sql) or Die (Mysql_error ());
$num =mysql_affected_rows ();
if ($num ==0)
$msg =1;
else
$msg =0;
echo $msg;/return value
mysql_close ($link);
? >
I hope this article will help you with the jquery program design.