码迷,mamicode.com
首页 > Web开发 > 详细

xmlhttp实例

时间:2014-12-24 23:54:30      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:

<script type="text/javascript">
function GetItemText(itemid,vtype)
{
var pstr="";
var itemtext="";
alert(itemid+‘,‘+vtype);
if(vtype==1)
{
itemtext=document.getElementById(itemid).value;
pstr="{%localhost%}/"+"?a=1&b=2";
alert(pstr);

}
if(pstr=="") return;
var xmlhttp;

if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
str=xmlhttp.responseText;
alert(str);
if (xmlhttp.readyState==4&&xmlhttp.status==200)
{
str=xmlhttp.responseText;
alert(str);
document.getElementById("txtHint").innerHTML=str;

}
}

xmlhttp.abort() ;
xmlhttp.open("GET",pstr,true);
xmlhttp.setRequestHeader("No-Cache","1");
xmlhttp.setRequestHeader("Pragma","no-cache");
xmlhttp.setRequestHeader("Cache-Control","no-cache");
xmlhttp.setRequestHeader("Expire","0");
xmlhttp.setRequestHeader("Last-Modified","Wed, 1 Jan 1997 00:00:00 GMT");
xmlhttp.setRequestHeader("If-Modified-Since","-1");

xmlhttp.send();

}
</script>

xmlhttp实例

标签:

原文地址:http://www.cnblogs.com/HuiLove/p/4183617.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!