当前位置: 移动技术网 > IT编程>脚本编程>Ajax > javascript ajax功能函数

javascript ajax功能函数

2017年12月12日  | 移动技术网IT编程  | 我要评论
复制代码 代码如下://ajax测试 var xmlhttp; function createxmlhttprequest(){ if(window.activexobje
复制代码 代码如下:

//ajax测试
var xmlhttp;
function createxmlhttprequest(){
if(window.activexobject){
xmlhttp=new activexobject("microsoft.xmlhttp");
}
else if(window.xmlhttprequest){
xmlhttp=new xmlhttprequest();
}
}
function a(){
createxmlhttprequest()
url="${request.contextpath}/test/formain.action";
alert(url);
statechange;
xmlhttp.open("get",url,true);
xmlhttp.send(null);
alert(xmlhttp.responsetext);
}
function statechange(){
alert(xmlhttp.status);
if(xmlhttp.readystate == 4){//描述一种"已加载"状态;此时,响应已经被完全接收。
if(xmlhttp.status == 200){//200表示成功收到
alert("成功");
return xmlhttp.responsetext; //返回值
}
else{
alert("失败");
}
}
}

如您对本文有疑问或者有任何想说的,请 点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网