ASP.NET XMLHTTPRequest AJAX

原文链接:http://hi.baidu.com/freesunshine/blog/item/a8f62ff30f250dcc0b46e094.html

<script langage=javaScript>

var xmlHttp;

function createXmlHttpRequest()

{

if(window.XMLHttpRequest)

{

xmlHttp=new XMLHttpRequest();

if(xmlHttp.overrideMimeType)

{

xmlHttp.overrideMimeType("text/xml");

}

}

else if(window.ActiveXObject)

{

try

{

xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");

}

catch(e)

{

xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");

}

}

if(!xmlHttp)

{

window.alert("你的浏览器不支持创建XMLhttpRequest对象");

}

return xmlHttp;

}

function ValidateCode(jobNo,lock)

{

createXmlHttpRequest();

var url="test/aaaa.aspx?jobNo="+jobNo+"&Lock="+lock;

xmlHttp.open("GET",url,true);

xmlHttp.onreadystatechange=ValidateResult;

xmlHttp.send(null);

}

function ValidateResult()

{

if(xmlHttp.readyState==4)

{

if(xmlHttp.status==200)

{

window.alert(xmlHttp.responseText);

window.location.reload();

}

}

}

</SCRIPT>

aaaa.aspx

Response.Write("OK!");

Response.Flush();//发送响应

Response.End();