![]() |
|
var req = new XMLHttpRequest();
var req = new ActiveXObject("Microsoft.XMLHTTP");
通过查看XMLHTTP相关的语法。
abort() |
Stops the current request |
getAllResponseHeaders() |
Returns complete set of headers (labels and values) as a string |
getResponseHeader("headerLabel") |
Returns the string value of a single header label |
open("method", "URL"[, asyncFlag[, "userName"[, "password"]]]) |
Assigns destination URL, method, and other optional attributes of a pending request |
send(content) |
Transmits the request, optionally with postable string or DOM object data |
setRequestHeader("label", "value") |
Assigns a label/value pair to the header to be sent with a request |
var req;
function loadXMLDoc(url) {
req = false;
if(window.XMLHttpRequest && !(window.ActiveXObject)) {
try {
req = new XMLHttpRequest();
} catch(e) {
req = false;
}
} else if(window.ActiveXObject) {
try {
req = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
req = false;
}
}
}
if(req) {
req.onreadystatechange = processReqChange;
req.open("GET", url, true);
req.send("");
}
}
有关XMLHTTP参数设置查看
onreadystatechange | Event handler for an event that fires at every state change |
readyState | Object status integer: 0 = uninitialized 1 = loading 2 = loaded 3 = interactive 4 = complete |
responseText | String version of data returned from server process |
responseXML | DOM-compatible document object of data returned from server process |
status | Numeric code returned by server, such as 404 for "Not Found" or 200 for "OK" |
statusText | String message accompanying the status code |
| 版权所有 www.safaricn.com 2006-2007 Safari中文网 |