XMLHTTP如何返回数据。

yanjinbin01 2007-04-12 09:28:44
<html>
<head><title>这是显示桢</title>
</head>
<body >
<form action="" name="myform" id="myform" method="post">
<input type="text" name="text1" id="text1" />
<input type="button" value="查找" onClick="requestcust();" />
</form>
<div id="divcust"></div> <!--用来显示传递过来的数据的,一开始是不显示的,等待写入数据显示-->
<script language="javascript">
function requestcust(){
try{
var sid=document.getElementById("text1").value;
var oxmlhttp=new ActiveXObject("Microsoft.XmlHttp");
oxmlhttp.open("GET","getcustomerdata.asp?id="&sid,false);
oxmlhttp.send(null); //只有先执行了send才会有responseText返回值。
//你都不发送怎么会有值呢。
alert(oxmlhttp.responseText);

}
catch(err){
alert(err.message);
}
}
</script>
</body>
</html>
后台接收页是getcustomerdata.asp
代码就是:<%
response.write request.QueryString("id")
%>
但为什么会接收不到值啊。
responseText现实出一大片的网页代码这是为什么。我只要id的值啊/
求解
...全文
244 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Suntears 2007-04-12
  • 打赏
  • 举报
回复
如果是一大片网页代码,可能是还有<html><body>等等这些东西.把这些全部删掉,asp页面只留下:<%
response.write request.QueryString("id")
%>
这一行。
yanjinbin01 2007-04-12
  • 打赏
  • 举报
回复
OK了。知道怎么回事了。谢谢。

52,797

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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