<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>xmlHTTP使用get方式得到数据</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="JavaScript">
<!--
function get()
{
var XMLHTTP = new ActiveXObject("Microsoft.XMLHTTP");
XMLHTTP.open("get","http://www.baidu.com",false);
// XMLHTTP.setRequestHeader("Context-Type","text/xml");
// XMLHTTP.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded");//
XMLHTTP.send();
document.all.xmlDiv.innerHTML = XMLHTTP.responseText;
alert(XMLHTTP.responseText)
}
//-->
</script>
</head><body>
<button onClick="get()">Get XML</button>
<div id="xmlDiv"></div>
</body>
</html>

解决方案 »

  1.   

    这里也发?<%
    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,"GB2312")
        set http=nothing
        if err.number<>0 then 
    err.Clear
    end if

    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.google.com"
    Html = getHTTPPage(Url)
    Response.write (Html)
    %>
      

  2.   

    恩,我其实是想分别用js和asp实现的…………
      

  3.   

    对比了一下XMLHTTP还是不错,不过我是想了解其它的实现方式,
    而且主要是能够发现问题。