Ajax1-php (27), ajax1php2

Source: Internet
Author: User

Ajax1-php (27), ajax1php2

1 Introduction

Working principle of web programs:

Working principle of traditional web programs:

Ii. core objects

XMLHttpRequest

1. Create an object

In different browsers, the method for creating ajax objects is slightly different.

IE:

New ActiveXObject ("Microsoft. XMLHTTP ")

Iii. Ajax object attributes and methods:

1. Related methods:

L open (method, url)

Initialize ajax objects

 

Method: Request method post, get

 

Url: Request resource address

L setRequestHeader (header, value)

 

Set Request Header Information

Header: Header information

Value: Value

 

L send (content)

Send request

 

Content: The passed parameter must be placed here only when the post request is made.

2. related attributes:

L readyState

The status code of the Ajax object, which changes at any time

0: indicates that the object has been created but not initialized.

1: indicates that the object has been initialized but not sent

2: The send method has been called for the request.

3: receiving data (receiving part)

4: Received

 

L onreadystatechange

The callback function triggered when the status code of the ajax object changes.

 

L status

Http response status code

 

L statusText

Http response text

 

L responseText

Http Response content text

 

L responseXML

Xml data of http Response content

 

There are three main ways to transmit Ajax object data:

Text: responseText

Xml: reponseXML

Json: responseText

 

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.