var xmlHttp;
function createXMLHttpRequest()
{
if (window.ActiveXObject)
{
xmlHttp = new ActiveXObject( "Microsoft.XMLHTTP ");
}
else if (window.XMLHttpRequest)
{
xmlHttp = new XMLHttpRequest(); }
}
function startRequest()
{
createXMLHttpRequest();
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.open( "GET ", "http://www.abcde.com/ ", true);
xmlHttp.send(null);
}
function handleStateChange()
{
if(xmlHttp.readyState == 4)
{
if(xmlHttp.status == 200)
{
}
}
else
{
}
}
可以用HttpWebRequest判断返回的Http_Code
根据HTTP协议非200就是非正常状态
本文介绍了一种使用JavaScript实现的Ajax GET请求方法,通过创建XMLHttpRequest对象并设置其onreadystatechange事件处理函数,来异步获取网页内容。文章还提到了如何判断HTTP响应的状态码来确定请求是否成功。

被折叠的 条评论
为什么被折叠?



