主题:XMLHTTP如何返回数据。
<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的值啊/
求解
<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的值啊/
求解