httpRequest.Open "POST", "www.example.com/handle.asp", False
httpRequest.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
httpRequest.send data
postResponse = httpRequest.response
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?
To send data using the HTTP POST method, you must include the data in the body of the HTTP POST message and specify the MIME type of the data with a Content-Type header. Below is an example of an HTTP POST request to send JSON data to the server. The size and data type for HTTP POST requests is not limited.
The POST Method POST is used to send data to a server to create/update a resource. Some notes on POST requests: POST requests are never cached. POST requests do not remain in the browser history.
Yes, you can make it work at least using WCF, it's bit different in MVC and Web API where you add attributes to methods like [GET] [POST] etc..
@Uzi: Here's an example --
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
Example of 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With