/* Create a new XMLHttpRequest object to talk to the Web server */
var xmlHttp = false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
xmlHttp = false;
}
}
@end @*/
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
xmlHttp = new XMLHttpRequest();
}
function callServer() {
// Build the URL to connect to
var url = "/test.aspx?id=" + escape(id) + "&name=" + escape(name);
// Open a connection to the server
xmlHttp.open("GET", url, true);
// Setup a function for the server to run when it's done
xmlHttp.onreadystatechange = updatePage;
// Send the request
xmlHttp.send(null);
}
function updatePage() {
if (xmlHttp.readyState == 4) {
var response = xmlHttp.responseText;
}
}
if (xmlHttp.readyState == 4) {
var response = xmlHttp.responseText;
}
}
posted @ 2006-08-04 15:20 dannyr|一个都不能少! 阅读(195) 评论(0) 编辑
Object Methods
Common XMLHttpRequest Object Methods
| Method | Description |
|---|---|
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 |
Object Properties
Common XMLHttpRequest Object Properties
| Property | Description |
|---|---|
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 |
posted @ 2006-08-04 15:11 dannyr|一个都不能少! 阅读(152) 评论(0) 编辑

