ajax与.net问题,急等,请救援

xutongfu 2009-06-16 04:14:44
function GetData()
{
var xmlReceive=createAjaxObj();
try{
//xmlReceive.abort();
xmlReceive.open("GET","~/setting/mytest1.aspx?action=inithtml&ID=13",true);

xmlReceive.setRequestHeader("Content-type", "text/html;charset=gb2312");

xmlReceive.setRequestHeader("If-Modified-Since","0");

xmlReceive.setRequestHeader("Content-length", 0);

xmlReceive.setRequestHeader("Connection", "close");

xmlReceive.onreadystatechange=function ShowComment1()
{
if(xmlReceive.readyState==4 && xmlReceive.status==200)
$("ShowData").innerHTML=xmlReceive.responseText;
}

xmlReceive.send(null);

}catch(ex){}
}

如上,小弟想在test.htm文件加裁时,向服务器请求数据,test.htm如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<body onload ="javascript:GetData();" >
。。。

现在的问题是xmlReceive.status的值经测试后为3,xmlTeceive.readyState=4正常,xmlReceive.statusText=unknown
亦即请求后,返回不了数据,是何问题?

补充:我现在的环境是VS2005+sqlServer2005!
...全文
43 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
kldx5092 2009-06-18
  • 打赏
  • 举报
回复
xmlReceive.open("GET","~/setting/mytest1.aspx?action=inithtml&ID=13",true);
url中~换成.或者..试试
yanm7788 2009-06-18
  • 打赏
  • 举报
回复
xmlReceive.open("GET","~/setting/mytest1.aspx?action=inithtml&ID=13",true);
这里能取到值吗?
修改一下昵称 2009-06-18
  • 打赏
  • 举报
回复
帮顶。
wts_net 2009-06-18
  • 打赏
  • 举报
回复
帮顶。
walkghost 2009-06-18
  • 打赏
  • 举报
回复
xmlReceive.open("GET","~/setting/mytest1.aspx?action=inithtml&ID=13",true);
xmlReceive.open("GET","../setting/mytest1.aspx?action=inithtml&ID=13",true);
psy0324 2009-06-17
  • 打赏
  • 举报
回复
建议楼主用Jquery 实现AJax效果 很容易。。。。
xutongfu 2009-06-16
  • 打赏
  • 举报
回复
我试过了,还是不对哦!
maddemon 2009-06-16
  • 打赏
  • 举报
回复
是不是你的ContextType有问题啊? application/x-www-form-urlencoded

111,093

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧