ajax.js
来自「CallSun 人才招聘求职系统 V2.20」· JavaScript 代码 · 共 79 行
JS
79 行
// 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 + =
减小字号Ctrl + -
显示快捷键?