阮一峰的IT笔记:首页 -> 分类 -> Javascript 查看所有文章:按分类 | 按月份

XMLHttpRequest对象的方法

1. open

格式:void open(string method, string url, boolean asynch, string username, string password)

共有5个参数,前两个是必需的,后三个是可选的。

method,调用的方法,GET, POST 和PUT。

url,网址。

asynch,该调用是否异步,默认值为true。如果设为false,则浏览器就会等待,直到服务器返回响应为止。

username和password,用户名和密码。

2. send

格式: void send(content)

这个方法用来向服务器发送请求。

3. setRequestHeader

格式:void setRequestHeader(string header, string value)

用来设定HTTP请求中的头信息。

这个方法必须在调用open()后使用。

4. abort

格式:void abort()

这个方法用来停止请求。

5. getAllResponseHeaders()

格式:string getAllResponseHeaders()

该方法返回一个字符串,包含HTTP响应中的头信息。

6. getResponseHeader

格式:getResponseHeader(string header)

得到HTTP头信息中某个指定项的值,并把这个值作为字符串返回。。

« 创建XMLHttpRequest对象的一个实例 | 首页 | XMLHttpRequest属性 »

About

This page contains a single entry from the blog posted on 2007年05月05日 17:14.

The previous post in this blog was 创建XMLHttpRequest对象的一个实例.

The next post in this blog is XMLHttpRequest属性.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.33

Post a comment