本文介绍了如何在ASP中发送和处理Http Post?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
httpRequest.Open "POST", "www.example.com/handle.asp", False
httpRequest.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
httpRequest.send data
postResponse = httpRequest.response
我该如何处理以上代码.在handle.asp中.在句柄中,我想获取要发送的数据并添加到其中,然后再将某些内容发送回调用页面?
How do i handle the post of the above code. in handle.asp. In handle i want to take the data being sent and add to it and then send something back to the calling page?
推荐答案
@Uzi:这是一个示例-
@Uzi: Here's an example --
somefile.asp
调用作为处理脚本的handle.asp
:
somefile.asp
calling handle.asp
which is the processing script:
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
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
这篇关于如何在ASP中发送和处理Http Post?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!