Some additions to Ajax applications

Source: Internet
Author: User
Tags call back end
Ajax

The emergence of Ajax concept, opened the era of refreshing update page, and there is a substitute for traditional web development in the form (form) submitted to update the Web page trend, can be regarded as a milestone. But Ajax does not apply to all places, its scope is determined by its characteristics. Through my days of Ajax learning after the understanding of the main characteristics of its 2 points:

1, according to the need to take data. Instead of reading useless redundant data, the page sends a request to the server when an interaction in the user's operation requires some data.

2, no Refresh update page. The client uses XMLHTTP to send a request for server-side response data and uses JavaScript to eventually update the page without loading the entire page.

3, read-through can also be achieved through Ajax, but not the advantages of Ajax, its main advantage or in the interactive aspect.

The positive effects of Ajax:

1, reduce the burden on the server. Because the fundamental idea of Ajax is "on-demand data," it is most likely to reduce the burden on the server of redundant requests and shadows.

2, reduce the user's actual and psychological waiting time.

First of all, the "on-demand data" model reduces the actual amount of data read, playing a very figurative analogy, if the overloaded way from one end to the original point to the other end of the words, then Ajax is to a point of origin to reach another end point;
Second, even if you want to read the larger data, and do not have the same white screen as reload, because Ajax is sent with the XMLHTTP request to get the server response data, without reload the entire page in the case of using JavaScript Operation Dom Final update page, So in the process of reading the data, the user is not faced with a white screen, but the original page state (or can add a loading hint box to let the user understand the state of the data read), only after receiving all the data to update the corresponding part of the content, and this update is instantaneous, users almost feel. In short, users are very sensitive, they can feel your thoughtfulness to them, although not likely immediate results, but in the user's mind a little bit of accumulation of their dependence on the site.

For example, one of the recommendations of Kyung Hsiang is that it is suitable for Ajax and is about AJAX applications in cascading menus.


Our previous approach to cascading menus is this:

In order to avoid the overloaded pages that are caused by each operation on the menu, instead of using each call back to the background, all the data for the cascading menu is read out and written to the array, and then the rendering of the subset item is controlled by JavaScript according to the user's action, which solves the response speed, Do not overload the page and avoid sending requests frequently to the server. However, if the user does not operate the menu or only a part of the menu, the read data will become redundant data and a waste of the user's resources, especially in the context of complex menu structure, the large amount of data (menu has many levels, There are hundreds of items in each class, such as the Reading channel among the UE, which is more prominent.

If Ajax is applied in this case, the results will be improved:

When we initialize the page, we only read all the data from its first level and show that when a user operates one of the first-level menus, all data for the level Two submenu to which the current level of the project belongs is requested by Ajax to the back desk, and if you continue to request an item from the level two menu that is already rendered, And then to request all the data of all level three menus for the two-level menu item that you are working on, and so on ... In this way, take what you use, take as much as you can, there will be no data redundancy and waste, reduce the total number of data downloads, and update the page without overloading the entire content, only update the part that needs to be updated, relative to the background processing and overloading of the way to shorten the user waiting time, but also to minimize the waste of resources.



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.