You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.1 KiB
54 lines
1.1 KiB
5 months ago
|
|
||
|
function AJAX()
|
||
|
{
|
||
|
this.Http = false;
|
||
|
this.Http = this.createXMLHttpRequest();
|
||
|
this.value = null;
|
||
|
this.xmlValue = null;
|
||
|
this.state = false;
|
||
|
}
|
||
|
AJAX.prototype.author = function()
|
||
|
{
|
||
|
alert("ajax for liyuanchao\n2007-12-01");
|
||
|
}
|
||
|
AJAX.prototype.help = function()
|
||
|
{
|
||
|
var str = "var ajax = new AJAX();\n";
|
||
|
str += "ajax.post(url);\n";
|
||
|
str += "if(ajax.isOK()) \n{\n var value = ajax.getValue();\n}";
|
||
|
alert(str);
|
||
|
}
|
||
|
AJAX.prototype.createXMLHttpRequest = function()
|
||
|
{
|
||
|
if(window.ActiveXObject)
|
||
|
return new ActiveXObject("Microsoft.XMLHTTP");
|
||
|
else if(window.XMLHttpRequest)
|
||
|
return new XMLHttpRequest();
|
||
|
}
|
||
|
AJAX.prototype.post = function(url)
|
||
|
{
|
||
|
this.Http.open("POST", url, false);
|
||
|
this.Http.send(null);
|
||
|
if(this.Http.readyState==4)
|
||
|
{
|
||
|
if(this.Http.status==200)
|
||
|
{
|
||
|
this.state = true;
|
||
|
this.value = this.Http.responseText;
|
||
|
this.xmlValue = this.Http.responseXML;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
AJAX.prototype.getValue = function()
|
||
|
{
|
||
|
return this.value;
|
||
|
}
|
||
|
AJAX.prototype.getXmlValue = function()
|
||
|
{
|
||
|
return this.xmlValue;
|
||
|
}
|
||
|
AJAX.prototype.isOK = function()
|
||
|
{
|
||
|
return this.state;
|
||
|
}
|