httpRequest.Open "POST", "www.example.com/handle.asp", False
httpRequest.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
httpRequest.send data
postResponse = httpRequest.response
Run Code Online (Sandbox Code Playgroud)
我如何处理上述代码的帖子.在handle.asp中.在句柄中我想收集发送的数据并添加到它然后发回一些东西回到调用页面?
ste*_*nja 21
@Uzi:这是一个例子 -
somefile.asp调用handle.asp哪个是处理脚本:
Option Explicit
Dim data, httpRequest, postResponse
data = "var1=somevalue"
data = data & "&var2=someothervalue"
data = data & "&var3=someothervalue"
Set httpRequest = Server.CreateObject("MSXML2.ServerXMLHTTP")
httpRequest.Open "POST", "http://www.example.com/handle.asp", False
httpRequest.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
httpRequest.Send data
postResponse = httpRequest.ResponseText
Response.Write postResponse ' or do something else with it
Run Code Online (Sandbox Code Playgroud)
示例handle.asp:
Option Explicit
Dim var1, var2, var3
var1 = Request.Form("var1")
var2 = Request.Form("var2")
var3 = Request.Form("var3")
' Silly example of a condition / test '
If var1 = "somecondition" Then
var1 = var1 & " - extra text"
End If
' .. More processing of the other variables .. '
' Processing / validation done... '
Response.Write var1 & vbCrLf
Response.Write var2 & vbCrLf
Response.Write var3 & vbCrLf
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
40657 次 |
| 最近记录: |