SearchWay="N"
CompanyName="餐饮集团"
StrPost="CompanyName="&CompanyName&"&SearchWay="&SearchWay&""
StrPost=toUTF8(StrPost)
Set Http = Server.CreateObject("MSXML2.XMLHttp")
Http.Open "Post","http://127.0.0.1/SearchList.asp",False
'//如果你硬要用request.form("CompanyName")来接收值,加入这一句
Http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
Http.Send StrPost
'//如果你返回的是文本信息,用下面接收
ReSult = Http.ResponseText
'//如果你返回的是HTML文件,用下面接收
'ReSult = bytes2BSTR(Http.ResponseBody)
Response.Write ReSult
'//这个是返回HTML文件信息时用的函数,如果返回文本信息,可以不需要这个函数
Function bytes2BSTR(vIn)
Dim strReturn
Dim I, ThisCharCode, 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
'//这个是对POST内容进行编码的函数
Function toUTF8(szInput)
Dim wch, uch, szRet
Dim x
Dim nAsc, nAsc2, nAsc3
If szInput = "" Then
toUTF8 = szInput
Exit Function
End If
For x = 1 To Len(szInput)
wch = Mid(szInput, x, 1)
nAsc = AscW(wch)
If nAsc < 0 Then nAsc = nAsc + 65536
If (nAsc And &HFF80) = 0 Then
szRet = szRet & wch
Else
If (nAsc And &HF000) = 0 Then
uch = "%" & Hex(((nAsc 2 ^ 6)) Or &HC0) & Hex(nAsc And &H3F Or &H80)
szRet = szRet & uch
Else
uch = "%" & Hex((nAsc 2 ^ 12) Or &HE0) & "%" & _
Hex((nAsc 2 ^ 6) And &H3F Or &H80) & "%" & _
Hex(nAsc And &H3F Or &H80)
szRet = szRet & uch
End If
End If
Next
toUTF8 = szRet
End Function
%>
SearchList.asp文件内容
if request.form("SearchWay")="N" then
response.write request.form("companyname")
else
response.write "NO VALUE"
end if
%>
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/767354/viewspace-916948/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/767354/viewspace-916948/