var xmlHttp = false;
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
xmlHttp = false;
}
}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
xmlHttp = new XMLHttpRequest();
}
function callServer() {
xmlHttp.open("GET","/xg.asp", true);
xmlHttp.onreadystatechange = updatePage;
xmlHttp.send(null);
}
function updatePage(id,divid) {
if (xmlHttp.readyState < 4) {
test1.innerHTML="<div style='text-align:center;color:ff0000'>读取数据库中...</div>";
}
if (xmlHttp.readyState == 4) {
var response = xmlHttp.responseText;
test1.innerHTML=response;
}
}
下面是XG.ASP页面部分
<% Response.charset = "utf-8" %>
<%function getHTTPPage(url)
dim Http
set Http=server.createobject("MSXML2.XMLHTTP")
Http.open "get",url,false
Http.send()
if Http.readystate<>4 then
exit function
end if
getHTTPPage=BytesToBSTR(Http.responseBody,"utf-8")
'xmlhttp.setRequestHeader("charset", "utf-8");
set http=nothing
if err.number<>0 then err.Clear
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
Dim Url,Html
Url="http://www.weather.com.cn/data/cityinfo/101210501.html" ‘这里是JS部分
Html = getHTTPPage(Url)
Response.write Html
%>