Ajax basics and logon tutorials

Source: Internet
Author: User

Ajax basics and logon tutorials

Ajax is short for Asynchronous Javascript and XML.

Advantages of Ajax:

Advantage: reduces the burden on the server, obtains data on demand, and minimizes redundant requests.

Partial page refresh to reduce user psychology and actual waiting time, and bring a better user experience

Xml-based standardization, widely supported, and plug-ins not required

Further promote the separation of pages and Data

Ajax includes the following technologies:

Representation based on the web Standard (standards-based presentation) XHTML + CSS;

Use DOM (Document Object Model) for Dynamic Display and interaction;

Use XML and XSLT for data exchange and related operations;

Use XMLHttpRequest for asynchronous data query and retrieval;

Use Javascript to bind everything together.

That is to say, the biggest feature of Ajax is that it can achieve dynamic non-Refresh.

Use Ajax:

Example:

A table in the database:

Click to check whether the user name is available:

Homepage code:

<! DOCTYPE html> 

The processing page is as follows:

<? Php $ zhang = $ _ POST ["yhm"]; // value include ("db. class. php "); $ db = new db (); $ SQL =" select count (*) from mydb where zhang = '{$ zhang }'"; $ arr = $ db-> Query ($ SQL); echo $ arr [0] [0]; // The direct output is equivalent to the return result?>

Figure:

Enter an existing User Name:

Enter a user name that does not exist:

Then write a login:

Logon Page code:

<! DOCTYPE html> 

Next is the login processing page:

<? Phpinclude ("db. class. php "); $ db = new db (); $ zhang = $ _ POST [" zhang "]; $ mi = $ _ POST [" mi "]; // value: $ SQL = "select mi from mydb WHERE zhang = '{$ zhang}'"; $ arr = $ db-> Query ($ SQL ); if ($ arr [0] [0] ==$ mi &&! Empty ($ mi) {echo "OK" ;}else {echo "no" ;}?>

If the input is incorrect, the following message is displayed on this page:

Jump to the right of the input:

The advantage of using Ajax to write logs is that when an error is prompted, you do not need to jump to another page.

The above section describes the Ajax basics and logon tutorials. I hope this will help you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!

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.