Jquery + ajax implement real-time verification instance registration details _ jquery

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.