The jQuery example describes when to use ajax, where to use ajax, and jqueryajax.

Source: Internet
Author: User

The jQuery example describes when to use ajax, where to use ajax, and jqueryajax.

Ajax is a very convenient tool for website development. It has the same functions as forms to complete frontend and backend interaction! It provides the partial refresh function! When Will ajax be used? We will introduce several instances as follows:

 

1. When forms and ajax can be used to complete a function, ajax is more convenient and convenient.

1. Use ajax in the comments below the website article! It uploads content to the background using ajax when users submit comments, and transmits background data to the page using js. This process only refreshes the comment module of the page, and other content such as the article is not refreshed. Is this much faster than the form?

 

2. ajax can be used for partial page flip. For example, if there are too many comments in the article, we need to pagination, so we can use ajax, like the above, he only refreshed the comments on the page and did not refresh the article, thus improving the speed!

 

2. Some function forms cannot be implemented. You can only use ajax!

1. Check the following search function.

If I use a form to submit information for searching products, then I can transmit the data! This will cause a problem, that is, when you refresh the page, it cannot return to the original page or keep the page where you search for the product. This is only done using ajax!

 

2. Check whether the user name exists during user registration! This is an event that retrieves the user's mouse and leaves the registration box, submits the user's account to the background for verification, and then returns back to the foreground information based on the verification situation. This form cannot be done! Of course, you can verify the registration information when the user submits all the registration information, so that the form can be used, but the user experience is poor!

 

3. We can use ajax to replace the iframe framework! This is easy to say!

 

Finally, pay attention to the following points when using ajax:

First, how to convert php Data into js arrays. You can read my other article, convert php arrays to js arrays, and how js receives PHP arrays. json usage

Second, when ajax is used to add or modify content on the page, the method for getting objects from common jQuery is invalid. In this case, you can use the live () or on () methods, jQuery gets the dynamically added elements, the difference between live and on

  

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.