補充回答:
你的動態頁只是一個請求頁。例如你新建一個 get.asp 頁面,用以下代碼,在服務端實現像URL異步(ajax)請求,將請求結果輸出。客戶端頁面再次用ajax(JS或者jquery的)向get.asp請求數據。兩次ajax完成異域數據請求。
get.asp代碼如下(參考)
reg="\\/]*).+\/{0,1}\>"
'函數名:GetResStr
'作用:獲取指定URL的HTML代碼
'參數:URL-要獲取的URL
function GetResStr(URL)
err.clear
dim ResBody,ResStr,PageCode,ReturnStr
Set Http=createobject("MiCROSOFT.XMLHTTP")
if URL="" then
response.Write("error!")
response.End()
else
Http.open "GET",URL,False
Http.Send()
If Http.Readystate =4 Then
If Http.status=200 Then
ResStr=http.responseText
ResBody=http.responseBody
PageCode=GetCode(ResStr,reg)
ReturnStr=BytesToBstr(http.responseBody,PageCode)
GetResStr=ReturnStr
End If
End If
End If
End Function
'函數名:BytesToBstr
'作用:轉換二進制數據為字符
'參數:Body-二進制數據,Cset-文本編碼方式
Function BytesToBstr(Body,Cset)
Dim Objstream
Set Objstream = 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
'函數名:GetCode
'作用:轉換二進制為字符
'參數:str-待查詢字符串,regstr-正則表達式
Function GetCode(str,regstr)
Dim Reg,serStr
set Reg= new RegExp
Reg.IgnoreCase = True
Reg.MultiLine = True
Reg.Pattern =regstr
if Reg.test(str) then '若查詢到匹配項
Set Cols = Reg.Execute(str)
serStr=Cols(0).SubMatches(0) '使用匹配到的第一個匹配項
else '否則給個默認值gb2312,有點省懶法,如果頁面沒給出編碼格式,想知道確實有點麻煩
serStr="utf-8"
end if
GetCode=serStr
end function
dim url:url=request.querystring("url")
response.write GetResStr(URL)
%>