关于XMLHTTP的问题
天空中国 2005-12-12 12:44:08
<%
On Error Resume Next
Server.ScriptTimeOut=9999999
Function getHTTPPage(Path)
t = GetBody(Path)
getHTTPPage=BytesToBstr(t,"GB2312")
End function
Function GetBody(url)
on error resume next
Set Retrieval = server.CreateObject("Microsoft.XMLHTTP")
With Retrieval
.Open "Get", url, False, "", ""
.setHeader "CONTENT-TYPE","application/x-www-form-urlencoded"
.Send
GetBody = .ResponseBody
End With
Set Retrieval = Nothing
End Function
Function BytesToBstr(body,Cset)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
%>
<%
url="http://192.168.0.6/chat/chat/refresh1.asp"
wstr=getHTTPPage(url)
%>
<script language="javascript">
function doloop()
{
document.write("111111");
document.write("<%response.write wstr%>");
setTimeout("doloop()",1000);
}
doloop();
</script>
wstr是通过XMLHTTP获得的,但是老是显示不出来,包括字符串"111111"都不能显示,
如果去掉 document.write("<%response.write wstr%>"); 能显示"111111",
这是为什么,通过XMLHTTP获得的数据怎么在JAVASCRIPT里显示啊,