52,797
社区成员
发帖
与我相关
我的任务
分享
<script type="text/javascript">
var xmlHttp;
function $(str){return document.getElementById(str);}
function createXmlHttp()
{
if(window.ActiveXObject)
{
xmlHttp=new ActiveXObject("msXml2.xmlHttp");
}else
{
xmlHttp=new XMLHttpRequest();
}
}
var DIV=document.createElement("div");
DIV.style.backgroundColor="#ccc";
DIV.innerHTML=" ";
document.body.appendChild(DIV);
function onReadyStateChange()
{
if(xmlHttp.readyState==4 && xmlHttp.status==200)
{
DIV.innerHTML=xmlHttp.status;
var text=xmlHttp.responseText;
DIV.innerHTML+=text;
}else
{
DIV.innerHTML="loading...";
}
}
function ajax()
{
createXmlHttp();
xmlHttp.onreadystatechange=onReadyStateChange;
xmlHttp.open("post","WebService.asmx/SayHi",true);
xmlHttp.setRequestHeader("Content-type","Appliction/x-www-from-urlencoded");
xmlHttp.send("name=value");
}
$("get").onclick=function()
{
ajax();
}
</script>