AJAX请求总是找不到URL 报404号错误
我的文件结构:
解决方案
WEB项目
index.htm
index.ashx
就是说 发起AJAX请求的页面和处理程序 ashx在同一个根目录下。
---------------------------------------------代码部分
var xmlHttp;
function hint()
{
xmlHttp=GetXmlHttpObject()
var url="index.ashx";
xmlHttp.onreadystatechange=stateChanged ;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
if(xmlHttp.status==200)
{
alert(xmlHttp.responseText);
}
}
在stateChanged 函数中用 调试断点检测, 可以看到 xmlHttp 的状态从1 变化到4
但是到3 的时候 或者4的时候,status总是为404
responseText 显示not found 404错误信息。
---------------------------------
为什么请求程序和处理程序在同一个文件夹下面总是找不到呢?
----------------------------------------
文件名是一定不会错的。以前测试过多次了。换过多个处理程序了。