Use ajax to improve your design

Source: Internet
Author: User
Example 1: Data Verification
When entering the form content, we usually need to ensure the uniqueness of the data. Therefore, the "unique verification" button is often provided on the page, allowing users to click to open a small verification window; or wait for the form to be submitted to the server, after being determined by the server, the server returns the corresponding verification information. The former is window. open operations are resource-consuming, usually by window. showmodaldialog is replaced by showmodaldialog. Even in this case, a dialog box is displayed. The latter submits the entire page to the server and the server determines the verification. This process takes a long time and increases the burden on the server. With Ajax, this verification request can be sent by the XMLHTTPRequest object. A new window does not need to be popped up or the entire page needs to be submitted to the server, which quickly does not burden the server. Example 2: On-Demand Data Acquisition-cascade menu
Previously, to avoid page overloading caused by each menu operation, instead of calling the background every time, all the data in the cascading menu was read at one time and written into the array, then, you can use JavaScript to control the presentation of its subset projects based on your operations. This solves the problem of operation response speed, no page overloading, and frequent requests sent to the server, however, if you do not operate the menu or only operate a part of the menu, a part of the read data will become redundant data and waste your resources, especially when the menu structure is complex and the data volume is large (for example, the menu has many levels and each level of food has hundreds of projects), this disadvantage is even more prominent.

Now with Ajax, when initializing the page, we only read all the data of its first level and display it. When one of the user operation level menus, ajax is used to request all data in the level-2 sub-menu of the current level-1 project to the background. If you continue to request an item in the level-2 menu that has already been displayed, then, request all data of all level-3 menus corresponding to the level-2 menu items to be operated, and so on ...... In this way, there will be no data redundancy and waste, reducing the total amount of data downloads, and you do not need to reload all content when updating the page, only the part to be updated can be updated. Compared with the background processing and reload method, the user wait time is shortened and the resource waste is minimized.

Example 3: Read external data
AJAX can call external data. Therefore, it can perform secondary processing on some developed data such as XML documents and RSS documents for data integration or application development.Program. 6. Ajax Defects

Ajax is not a perfect technology. When Ajax is used, some of its defects have to be weighed:

    • Ajax uses a lot of JavaScript and Ajax engines, depending on the support of browsers. Ie5.0 and later versions, mozilla1.0, netscape7 and later versions are supported. Although Mozilla also supports Ajax, XMLHttpRequest is provided in different ways. Therefore, Ajax programs must test the compatibility of various browsers.
    • When Ajax updates the page content, the entire page is not refreshed. Therefore, the page's back-up function is invalid. Some users often do not know whether the current data is old or updated. In this case, you need to clearly remind the user that "data has been updated ".
    • The support for streaming media is not as good as flash and Java applet.
    • Some handheld devices (such as mobile phones and PDAs) cannot support Ajax yet.

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.