xmlhttp实例

<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>

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。