You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
2.0 KiB
JavaScript
84 lines
2.0 KiB
JavaScript
// JavaScript Document
|
|
//创建XMLHttpRequest对象
|
|
function createXMLHttpRequest() {
|
|
|
|
if (window.XMLHttpRequest) { // Not IE
|
|
|
|
return new XMLHttpRequest();
|
|
|
|
} else if (window.ActiveXObject) { // IE
|
|
|
|
isIE = true;
|
|
|
|
return new ActiveXObject("Microsoft.XMLHttp");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//异步(true)提交网址及参数
|
|
|
|
function posturl(theurl) {
|
|
var xmlHttp = createXMLHttpRequest();
|
|
xmlHttp.open("GET", theurl, true); //异步(true
|
|
xmlHttp.send(null);
|
|
//alert(xmlHttp.readyState);
|
|
//alert(xmlHttp.status);
|
|
//alert(xmlHttp.responseText+"qqqq");
|
|
}
|
|
|
|
//提交网页请求并返回文本结果,并写入到相应的块
|
|
|
|
function postget(theurl,thediv) {
|
|
var xmlHttp = createXMLHttpRequest();
|
|
xmlHttp.open("GET", theurl, false);
|
|
xmlHttp.send(null);
|
|
//alert(xmlHttp.readyState);
|
|
//alert(xmlHttp.status);
|
|
//alert(xmlHttp.responseText+"qqqq");
|
|
var comm = document.getElementById(thediv);
|
|
comm.innerHTML=xmlHttp.responseText;
|
|
}
|
|
|
|
function postpost(theurl,thediv) {
|
|
var xmlHttp = createXMLHttpRequest();
|
|
xmlHttp.open("post", theurl, false);
|
|
xmlHttp.send(null);
|
|
//alert(xmlHttp.readyState);
|
|
//alert(xmlHttp.status);
|
|
//alert(xmlHttp.responseText+"qqqq");
|
|
var comm = document.getElementById(thediv);
|
|
comm.innerHTML=xmlHttp.responseText;
|
|
}
|
|
|
|
function postget2(theurl,thediv) {
|
|
var xmlHttp = createXMLHttpRequest();
|
|
xmlHttp.open("GET", theurl, false);
|
|
xmlHttp.send(null);
|
|
var comm = document.getElementById(thediv);
|
|
//alert(xmlHttp.status);
|
|
comm.value=xmlHttp.responseText;
|
|
}
|
|
function postget1(theurl,thediv) {
|
|
var xmlHttp = createXMLHttpRequest();
|
|
xmlHttp.open("GET", theurl, true);
|
|
xmlHttp.send(null);
|
|
var comm = document.getElementById(thediv);
|
|
//alert("BB");
|
|
//alert(xmlHttp.readyState);
|
|
//alert(xmlHttp.status);
|
|
//alert(xmlHttp.responseText);
|
|
//comm.innerHTML=xmlHttp.responseText;
|
|
xmlHttp.onreadystatechange = function() {
|
|
//alert("DD");
|
|
//alert(xmlHttp.readyState);
|
|
if (xmlHttp.readyState == 4) { // loaded
|
|
//alert(xmlHttp.status);
|
|
if (xmlHttp.status == 200) { // no http error
|
|
|
|
comm.innerHTML=xmlHttp.responseText;
|
|
}
|
|
}
|
|
}
|
|
//alert("EE");
|
|
} |