Ajax-Driven Web Site

Source: Internet
Author: User

Recently, many Web sites have begun to attract attention in the developer community. These sites are unique in that they are more like desktop applications than Web applications. When you interact with them, they can quickly display endless information in the browser without reloading the page.

For example, at the Google Maps site (http://maps.google.com/), you can click a map, zoom in or zoom in, and move the mouse back and forth as you like. The browser continuously reads data from the server, but does not need to refresh the browser. They are not using applets or other programs similar to Flash. So how do they work?

The following describes Asynchronous JavaScript + XML, which is called Ajax. The easiest way to accurately describe Ajax is to compare it with the opposite. For most Web sites, interacting with Web servers is the simplest way of communication-just like chatting with friends on a walkie Talie-talkie. You can answer your speech on the other side, or you can answer your speech, but you cannot answer or speak at the same time. For Web users, after entering the online form and clicking the submit button, the entire page will be sent to the Web server. Users must wait for the server to accept the request. When the server completes processing the request, it will send the processed content. Only then can the user page be refreshed. Ajax is an attempt to reduce this series of events. When a user is on an Ajax Web site, the browser can call the Web server asynchronously behind the scenes without sending the entire page.

Details

Generally, Ajax does not have a software development kit (SDK ). It is not something you can download. Although XML appears in Ajax names, it is actually a combination of several methods that can be used or even not used by XML technology. After careful research, we will find that it is a mixture of several technologies being used. JavaScript, DOM, XMLHttp, and XML are the main roles. But remember that this methodology is neither standard nor strictly defined. What you see in one execution program may be different from the situation in another execution program. However, JavaScript is the most common in Ajax execution programs.

When a user interacts with a browser, JavaScript code handles various events. For example, you can press a key or click an event and process it accordingly. JavaScript uses the XMLHttpRequest object as the connection between the browser and the remote server. Microsoft first uses the XMLHttpRequest object in Internet Explorer 5.

The coolest thing about the XMLHttp-Request object is that it can run in the background and asynchronously communicate with the Web server without reloading the page. When the Web server receives a browser request, it will process and return the processed XML data to the browser. The JavaScript Engine receives the processed XML data and uses DOM to process the corresponding page parts. For example, on an Ajax-driven page, such as a Google Suggest site (www.google.com/webhp? Complete = 1 & hl = en). When you enter a search field, each letter is asynchronously sent to the server. The entered content is quickly displayed below the body. Behind the scenes, each button is called several times to the server. The user is not affected because the interaction is not aborted. Only some pages are refreshed. All of this can be done efficiently, because only a portion of page data (rather than the entire page data) is sent through the cable.

Ajax is not a new thing

It should be noted that Ajax is not a new thing. This methodology has been used for many years. Web sites (such as Google) are proving the validity and Stability of Ajax, and make the Web look more like a desktop application: truly meaningful Web development. Ajax can do all of this with proven existing technologies. In other words, any standard browser (a browser that can handle JavaScript and DOM) can work normally. You do not need to install other plug-ins separately.

In Magenic, we can see how this methodology benefits our clients. As far as we know, Ajax cannot replace all Web sites, but it should have a place in computer command systems and be a skill we need.

ASP. Network 2.0

ASP. Net 2.0 can significantly improve the combination of the script model with this methodology. They are called script callbacks rather than Ajax. Actually, they work as I described earlier, but ASP. Net 2.0 takes it further by providing tools and support.

Notes

1. Because a lot of work must be handed over to the client for processing, Ajax will affect the command line between correctly stacked technologies. Pay attention to this when designing such applications using existing methodologies. The client (browser) needs to handle more work, and JavaScript needs to complete this work quite complicated. It needs to process buttons, mouse, interaction with DOM, process these events and coordinate server data.

2. Note that many users may not want to run JavaScript on their browsers. In this case, you need to consider the needs of Web site users.

3. Ajax names are informal. The Adaptive Path staff gave up this easy-to-remember name. In ASP. Net 2.0, it is also called "script callback ".


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.