ajax1—php(27),ajax1php27_PHP教程

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

ajax1—php(27),ajax1php27

一 简介

web程序工作原理图:

传统的web程序工作原理图:

ajax1—php(27),ajax1php27_PHP教程二、  核心对象

XMLHttpRequest

一、创建对象

在不同的浏览器下,创建ajax对象的方式略有不同。

IE下:

new ActiveXObject("Microsoft.XMLHTTP")

ajax1—php(27),ajax1php27_PHP教程三、Ajax对象相关属性和方法:

1、  相关方法:

l  open(method,url)

初始化ajax对象

 

method:请求方式    post、get

 

url:请求资源地址  

l  setRequestHeader(header,value)

 

设置请求头信息

Header:头信息

Value:值

 

l  send(content)

发送请求

 

Content:所传递的参数  只有在post请求时才需要将参数放在这里

2、  相关属性:

l  readyState

Ajax对象的状态码 ,这个状态码会随时改变

0:表示对象已建立,但未初始化

1:表示对象已初始化,但未发送

2:已调用send方法进行请求

3:正在接收数据(接收到一部分)

4:接收完成

 

l  onreadystatechange

当ajax对象的状态码发生改变时,所触发的回调函数

 

l  status

http响应状态码

 

l  statusText

http响应的文本

 

l  responseText

http响应内容的文本

 

l  responseXML

http响应内容的xml数据

 

Ajax对象数据的传递主要有三种方式:

Text:responseText

Xml:reponseXML

Json:responseText

 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/998221.htmlTechArticleajax1—php(27),ajax1php27 一 简介 web程序工作原理图: 传统的web程序工作原理图: 二、核心对象 XMLHttpRequest 一、创建对象 在不同的浏览器...
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!