我之前用的都是windows+iis跑php,现在转到了linux+apache,却发现原来主页上很多js调用都失效了,必须要把js内容写在首页里面才能正常使用。但是还有一个ajax却依旧无法工作,写在主页中也没用,提示无权限这个ajax是远程调用别的网站的一个页面的内容的var texthttp = null;var isIE = null;var TextDoc = null;var parser = null;var oSerializer = null;
if (window.ActiveXObject)
{
try
{
texthttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e)
{
texthttp = new ActiveXObject("MsXml2.XMLHTTP");
}
}
else
{
texthttp = new XMLHttpRequest();
isIE = false;
}function OpenFile(fName)
{
if(texthttp.readyState == 4 || texthttp.readyState == 0)
{
texthttp.open("GET",fName,true);
texthttp.onreadystatechange = fileonreadystatechange ;
//texthttp.send();
texthttp.send(null);
}
}
function fileonreadystatechange()
{
if (texthttp.readyState == 4)
{
TextDoc = texthttp.responseText;
///alert(TextDoc);
document.getElementById('infodiv').innerHTML=texthttp.responseText;
}
else
{
document.getElementById("infodiv").innerHTML="<img src='/images/loading.gif' /> Loading ...";
}
}
OpenFile("http://www.sohu.com/");
if (window.ActiveXObject)
{
try
{
texthttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e)
{
texthttp = new ActiveXObject("MsXml2.XMLHTTP");
}
}
else
{
texthttp = new XMLHttpRequest();
isIE = false;
}function OpenFile(fName)
{
if(texthttp.readyState == 4 || texthttp.readyState == 0)
{
texthttp.open("GET",fName,true);
texthttp.onreadystatechange = fileonreadystatechange ;
//texthttp.send();
texthttp.send(null);
}
}
function fileonreadystatechange()
{
if (texthttp.readyState == 4)
{
TextDoc = texthttp.responseText;
///alert(TextDoc);
document.getElementById('infodiv').innerHTML=texthttp.responseText;
}
else
{
document.getElementById("infodiv").innerHTML="<img src='/images/loading.gif' /> Loading ...";
}
}
OpenFile("http://www.sohu.com/");
Dim Body,S,O
Url="http://www.sohu.com"
Function PostData(PostUrl,PostMode)
Dim Http
Set Http = Server.CreateObject("msxml2.XMLHTTP")
With Http
.Open "POST",PostUrl,False
.SetRequestHeader "Content-Length",Len(PostStr)
.SetRequestHeader "Content-Type","application/x-www-form-urlencoded"
.SetRequestHeader "Referer",PostUrl
.Send PostStr
If PostMode=0 Then
PostData = .ResponseBody
Else
PostData = BytesToBstr(.ResponseBody,"gb2312")
End If
End With
Set Http = Nothing
End Function
Function BytesToBstr(Body,Cset)
Dim ADOS
Set ADOS = Server.CreateObject("Adodb.Stream")
With ADOS
.Type = 1
.Mode =3
.Open
.Write Body
.Position = 0
.Type = 2
.Charset = Cset
BytesToBstr = .ReadText
.Close
End With
Set ADOS = Nothing
End FunctionResponse.Write("·"&body)'输出
curl
sock
file_get_contents
com+xmlhttp (只限Windows环境)
实现,现成的代码很多。无需套改asp