Jquery+ajax implementation of registered real-time verification examples _jquery

Source: Internet
Author: User

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:
$.get ("test.php");

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.

Related Article

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.