请问javascript怎么发GET请求啊?各位大哥帮帮忙!!谢谢 通过写 location.href 或者 xmlhttp.open() 都可以发起 get 请求 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 var http = new ActiveXObject("Microsoft.XMLHTTP");http.open("Get","页面.asp?id=1",false);http.send();alert(http.responseText);//执行结果。 <script language="VBScript" >//解决中文显示问题Function bytes2BSTR(vIn)Dim strReturn,i,ThisCharCode,innerCode,Hight8,Low8,NextCharCodestrReturn = ""For i = 1 To LenB(vIn) ThisCharCode = AscB(MidB(vIn,i,1)) If ThisCharCode < &H80 Then strReturn = strReturn & Chr(ThisCharCode) Else NextCharCode = AscB(MidB(vIn,i+1,1)) strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode)) i = i + 1 End IfNextbytes2BSTR = strReturn End Function</script><script language="javascript">function XHConn(){ var xmlhttp, bComplete = false; try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp = false; }}} if (!xmlhttp) return null; this.connect = function(sURL, sMethod, sVars, fnDone) { if (!xmlhttp) return false; bComplete = false; sMethod = sMethod.toUpperCase(); try { if (sMethod == "GET") { xmlhttp.open(sMethod, sURL+"?"+sVars, true); sVars = ""; } else { xmlhttp.open(sMethod, sURL, true); xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1"); xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); } xmlhttp.onreadystatechange = function(){ if (xmlhttp.readyState == 4 && !bComplete) { bComplete = true; fnDone(xmlhttp); }}; xmlhttp.send(sVars); } catch(z) { return false; } return true; }; return this;}//回调函数var fnWhenDone = function (oXML) { alert(bytes2BSTR(oXML.responseBody));}var myConn = new XHConn();myConn.connect("http://www.baidu.com/s", "GET", "ct=0&ie=gb2312&bs=xmlhttp&sr=&z=&cl=3&f=8&wd=xmlhttp+%D6%D0%CE%C4", fnWhenDone);</script> var obj;obj = new ActiveXObject("MSXML2.XMLHTTP");if(!obj){ obj = new ActiveXObject("Microsoft.XMLHTTP");}obj .open("GET","url",false);obj .send();//obj.responseText为返回的内容 PAZU使用JS直接打印功能 讨论变量初始赋值的好处 大家一起来,Dom中Image类的问题。 求助!DIV层相关 求js交换2层代码 在js中怎样得到日期之间的差,请js高手指点!! 字符串替换问题 如何设置<span>标签的值 (紧急)光标移动传值的问题! 来人呀!来人呀!来人呀! 自写的一段动态LOAD JS函数,有点小BUG ●一个asp和js一起使用的问题?
http.open("Get","页面.asp?id=1",false);
http.send();
alert(http.responseText);//执行结果。
//解决中文显示问题
Function bytes2BSTR(vIn)
Dim strReturn,i,ThisCharCode,innerCode,Hight8,Low8,NextCharCode
strReturn = ""For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next
bytes2BSTR = strReturn
End Function
</script><script language="javascript">
function XHConn()
{
var xmlhttp, bComplete = false;
try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
catch (e) { try { xmlhttp = new XMLHttpRequest(); }
catch (e) { xmlhttp = false; }}}
if (!xmlhttp) return null;
this.connect = function(sURL, sMethod, sVars, fnDone)
{
if (!xmlhttp) return false;
bComplete = false;
sMethod = sMethod.toUpperCase(); try {
if (sMethod == "GET")
{
xmlhttp.open(sMethod, sURL+"?"+sVars, true);
sVars = "";
}
else
{
xmlhttp.open(sMethod, sURL, true);
xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
xmlhttp.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded");
}
xmlhttp.onreadystatechange = function(){
if (xmlhttp.readyState == 4 && !bComplete)
{
bComplete = true;
fnDone(xmlhttp);
}};
xmlhttp.send(sVars);
}
catch(z) { return false; }
return true;
};
return this;
}//回调函数
var fnWhenDone = function (oXML) {
alert(bytes2BSTR(oXML.responseBody));
}
var myConn = new XHConn();
myConn.connect("http://www.baidu.com/s", "GET", "ct=0&ie=gb2312&bs=xmlhttp&sr=&z=&cl=3&f=8&wd=xmlhttp+%D6%D0%CE%C4", fnWhenDone);
</script>
obj = new ActiveXObject("MSXML2.XMLHTTP");
if(!obj){
obj = new ActiveXObject("Microsoft.XMLHTTP");
}
obj .open("GET","url",false);
obj .send();
//obj.responseText为返回的内容