📄 ajax.js
字号:
// JScript 文件
function AjaxClass()
{
this.XmlHttp = null;
try
{
this.XmlHttp = new XMLHttpRequest();
}
catch(FFError)
{
try
{
this.XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(NewIEError)
{
try
{
this.XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(IEError)
{
this.XmlHttp = false;
}
}
}
if (this.XmlHttp == null)
{
alert("浏览器不支持AJAX");
return;
}
this.RequestUrl = "";
this.Method = "get";
this.IsAsyn = true;
this.ContentType = "text/html";
this.Content = null;
this.ProcessDataEvent = processData;
this.StateChangeEvent = handleStateChange;
this.SendRequest = function()
{
this.XmlHttp.onreadystatechange = this.StateChangeEvent;
try
{
this.XmlHttp.open(this.Method, this.RequestUrl, this.IsAsyn);
if (this.Method.toLowerCase() == "post")
{
this.XmlHttp.setRequestHeader("Content-Type",this.ContentType);
}
this.XmlHttp.send(this.Content);
}
catch(e)
{
alert(e.message);
}
}
function handleStateChange()
{
if (this.XmlHttp.readyState == 4)
{
if (this.XmlHttp.status == 200)
{
this.ProcessDataEvent();
}
}
}
function processData()
{
//
//在这里处理服务器返回数据
//
alert("ok");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -