Home > Backend Development > PHP Tutorial > ajax1—php (27), ajax1php27_PHP tutorial

ajax1—php (27), ajax1php27_PHP tutorial

WBOY
Release: 2016-07-13 09:54:20
Original
972 people have browsed it

ajax1—php (27), ajax1php27

1 Introduction

Web program working principle diagram:

Traditional web program working principle diagram:

ajax1—php (27), ajax1php27_PHP tutorial2. Core Object

XMLHttpRequest

1. Create objects

Under different browsers, the way to create ajax objects is slightly different.

Under IE:

new ActiveXObject("Microsoft.XMLHTTP")

ajax1—php (27), ajax1php27_PHP tutorial3. Ajax object related properties and methods:

1. Related methods:

l open(method,url)

Initialize ajax object

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 parameters passed only need to be placed here when making a post request

2. Related attributes:

l readyState

Status code of the Ajax object, this status code will change 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 to make a request

3: Receiving data (part of it received)

4: Reception completed

l onreadystatechange

When the status code of the ajax object changes, the callback function triggered

l status

http response status code

l statusText

Text of http response

l responseText

Text of http response content

l responseXML

xml data of http response content

There are three main ways to transfer Ajax object data:

Text: responseText

Xml: responseXML

Json:responseText

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/998221.htmlTechArticleajax1—php (27), ajax1php27 An introduction to the working principle diagram of the web program: The working principle diagram of the traditional web program: 2. Core object XMLHttpRequest 1. Create objects in different browsers...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template