function HttpRequest()
{
this.Request=function(){
try
{
if(window.XMLHttpRequest) request=new XMLHttpRequest();
if(!request)request=new ActiveXObject("Microsoft.XMLHTTP");
if(!request)request=new ActiveXObject("Msxml2.XMLHTTP");
if(!request) alert("不支持");
return request;
}
catch(e)
{
alert("不支持XMLHTTPRequest");
}}
}
//创建HttpRequest对象
var request=new HttpRequest().Request();
//设置监听方法
request.onreadystatechange=function (){
if(request.readyState==4)
{
if(request.status==200)
{
//请求成功执行代码 }
else
{
//请求失败执行代码 }
}
}
//使用Post方法向Url请求信息,异步调用(true)
request.open("POST",URL+Param,true);
request.setRequestHeader("Content-Type","text/html;charset=gb2312");
request.send(null);
}
}
Ajax-Request
最新推荐文章于 2021-08-05 21:47:12 发布