Use AJAX to build better Web Applications

Source: Internet
Author: User

I. Introduction

Asynchronous JavaScript + XML (Ajax) is a web development technology used to create interactive Web applications. This type of program uses JavaScript and XML to submit server requests from the client, and only a small amount of data needs to be exchanged throughout the process without submitting the entire web page. Therefore, such a program will be faster and more responsive, and will become one of the important basic technologies of the next-generation client-server system. Can you http://www.google.com/webhp at the site? Complete = 1 & hl = en shows a good demonstration of AJAX practices. On this page, if you enter any letter in the text box, a drop-down list box will appear. The content is directly from the server without submitting the entire page. The core of AJAX is the XMLHttpRequest object. The client can retrieve and directly submit XML data in the background. To convert the retrieved XML data into HTML content that can be generated, You need to rely on the client Document Object Model (DOM) to read the XML document node tree and form HTML elements visible to users. In fact, AJAX is not a single technology like HTML or DHTML. It combines different technologies:

◆ The XMLHttpRequest object is used to exchange data asynchronously with the web server.

◆ XML is generally used to transmit data back to the server (although it can be used in any format, such as plain text and HTML ).

◆ If XML is used as the conversion format, DOM is usually used with client scripting languages such as JavaScript to dynamically display and describe interaction information.

◆ XHTML (or HTML) and CSS are used for tag and information formatting.

Ii. XMLHttpRequest object

In history, Microsoft first implemented the XMLHttpRequest object in the form of an ActiveX Object in Internet Explorer 5 for Windows. Later, Mozilla engineering engineers implemented a compatible native version of Mozilla 1.0 (and Netscape 7), while Apple later achieved the same work on its Safari 1.2. In fact, similar functions are also mentioned in W3C standard Document Object Model (DOM) Level 3 loading and storage specifications. Now, it becomes a de facto standard and will be implemented in most browsers released in the future.

(1) create an object

The method for creating XMLHttpRequest objects varies with the browser. For Safari and Mozilla, the creation method is as follows:

var req = new XMLHttpRequest();

For Internet Explorer 5.0 + (5.0 and later), you must pass the object name to the ActiveX constructor:

var req = new ActiveXObject("Microsoft.XMLHTTP");

The method of this object controls all operations, and its attributes store various data fragments returned from the server, for example, XMLHttpObject. responseText contains xml or string values returned from the server.

(2) Method

The XMLHttpRequest objects supported in Windows IE 5.0 +, Safari 1.2, and ILA are listed as follows:

 

In the preceding method, the open and send methods are the most important. Next, let's first discuss the open method from the perspective of the application.

Var req ;........................... Req = new ActiveXObject ("Microsoft. XMLHTTP ");............... Var url = "AjaxServer. aspx? PubID = "+ ID ;............... // Open a GET request to the URL req. open ("GET", url, true); // actually send an empty request req. send (null );

  • Three pages in total:
  • Previous Page
  • 1
  • 2
  • 3
  • Next Page

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.