Creating a Cross-platform Ajax application

Source: Internet
Author: User
Tags object implement interface object model window
Ajax| Create
What is Ajax?
Ajax is not a new technology, it is the abbreviation of asynchronous JavaScript and XML. It is a combination of JavaScript and XML technology applications. The specific include:

DHTML and CSS
Dynamic display and interaction using the Document Object model
Data interaction and manipulation using XML and XSLT
Using XMLHttpRequest for asynchronous data reception
Use JavaScript to bind them together
With Ajax technology, we can achieve a rich Internet client interface to some extent. Let's take a look at an example. To design a web interface, the user selects a province from the Drop-down list and displays the city list of that province in another manifest list. These provinces have urban data that is stored in server-side databases. Before Ajax, when a user selects a province for each time in the browser, a form submission action occurs, sending the selected province through the form's post request to servlet/jsp, and then the server returns to another Web page containing the province's data. What the user sees in the browser is that the page is refreshed once, and there is a noticeable interface lag effect.

After the advent of Ajax technology, it all became a thing of the past. The user sees a web interface that is almost instantly refreshed. We'll discuss in detail how to implement this example on different browser platforms and what to note when writing scripts on different browsers.


XMLHttpRequest---The Soul of Ajax
To implement AJAX applications on the browser, you need to create a XMLHttpRequest script object that we use to allow JavaScript to interact with the server in the background asynchronously, and the interactive medium is XML.

XMLHttpRequest is not a standard technology [1] as defined by the consortium, so the way to create XMLHttpRequest objects differs from one browser to another.

1 var xmlhttp;2) if (window.    XMLHttpRequest) 3) {4)//Create Mozilla/firefox Platform XMLHttpRequest Object 5) xmlHttp = new XMLHttpRequest (); 6) else if (window. ActiveXObject) 7) {8)//Create Ie/windows Platform XmlHttp object 9) xmlHttp = new ActiveXObject ("Microsoft.XMLHTTP"); 10 )    }
The above code creates the XMLHttpRequest script object. The 5th line is the creation of the Firefox platform, I only tested on the Firefox platform, because Firefox is the use of Mozilla as the kernel, in theory can also run on Mozilla. Line 9th is how IE is created.

Fortunately, the methods and properties provided by these two objects are almost identical, although they are created differently.<

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.