This article mainly introduces jquery + ajax Real-time registration verification methods, and analyzes in detail jQuery's skills related to refreshing verification when registering based on ajax requests in combination with instance forms, for more information about how to use jquery + ajax to implement real-time registration verification, see the examples in this article. We will share this with you for your reference. The details are as follows:
When registering a user, we will prompt whether the user's information is available in real time. This is the ajax application. I have seen this implementation a long time ago and read it again today, record O (∩ _ ∩) O ha!
First, we will introduce $. get in ajax. since the usage of $. post is similar to that of $. get, we will not introduce it again:
This is a simple GET request function to replace complex $. ajax. You can call the callback function when the request is successful. To execute a function when an error occurs, use $. ajax.
The code is as follows:
$ (Selector). get (url, data, success (response, status, xhr), dataType)
Parameters |
Description |
Url |
Required. Specifies the URL of the request. |
Data |
Optional. Specifies the data sent to the server together with the request. |
Success (response, status, xhr) |
Optional. Specifies the function that runs when the request is successful. Additional parameters:
- Response-contains the result data from the request
- Status-contains the request status
- Xhr-contains XMLHttpRequest object
|
DataType |
Optional. Specifies the expected server response data type. By default, jQuery performs intelligent judgment. Possible types:
- "Xml"
- "Html"
- "Text"
- "Script"
- "Json"
- "Jsonp"
|
Request the test. php webpage and ignore the returned value:
The code is as follows:
$. Get ("test. php ");
More examples:
Example 1
Send two parameters to the test. php webpage and ignore the returned value:
The code is as follows:
$. Get ("test. php", {name: "John", time: "2 "});
Example 2
Display the test. php return value (HTML or XML, depending on the return value ):
$.get("test.php", function(data){ alert("Data Loaded: " + data);});
Example 3
Display the return value of test. cgi (HTML or XML, depending on the returned value), add a set of request parameters:
$.get("test.cgi", { name: "John", time: "2pm" },function(data){ alert("Data Loaded: " + data);});
The following is my code:
User registration