@ArindamNayak is absolutely right.
GET and POST Knowing the Differences
HTTP GET
requests passes the data as a serialised string of parameters separated by ampersand (&
) delimiters appended to the request URL, also known as a querystring.
HTTP POST
requests pass the data in the body of the request as serialised string of parameters in the same form as a GET
querystring.
Classic ASP makes it easy to access these values with two collections
Request Collections
Request.QueryString() - Contains all parameters requested via the GET
request method.
Request.Form() - Contains all parameters requested via the POST
request method.
Request() - Contains all parameters requested via either the GET
or POST
request methods.
NOTE: - This method is less efficient because the parameter has be checked in both the QueryString
and Form
collections, if you know where your data is coming from (whether it's a GET
or POST
request) it is best to use the corresponding collection.
Example Usage
If the following request is made
GET http://example.com/default.asp?phone=123456&message=test HTTP/1.1
In the page default.asp
the parameters can be accessed using either the Request.QueryString()
or Request()
collections.
<%
Dim message
'Retrieves parameter from Request.QueryString collection.
phone = Request.QueryString("message")
'Checks both Request.Form and Request.QueryString.
phone = Request("message")
Response.Write phone 'Returns "test"
%>
If the following request is made
POST http://example.com/default.asp HTTP/1.1
phone=12345&message=test
In the page default.asp
the parameters can be accessed using either the Request.Form()
or Request()
collections.
<%
Dim message
'Retrieves parameter from Request.Formcollection.
phone = Request.Form("message")
'Checks both Request.Form and Request.QueryString.
phone = Request("message")
Response.Write phone 'Returns "test"
%>
What About jQuery Ajax Requests?
jQuery makes a really easy to pass this information, the three properties you want to make sure are set correctly are;
url - The URL we are sending data to, do not include the querystring just the absolute / relative path to the Classic ASP page.
type - Either GET
or POST
depending on the intended request method.
data - The data we are sending to the URL. If it is type: "GET"
the data will be automatically serialised and attached during the AJAX request as a URL querystring.
Using my previous example the AJAX request would look something like this;
$.ajax({
type: "GET",
url: "http://example.com/default.asp",
data: {
phone: "12345",
message: "test"
}
});
will create a RAW HTTP request like
GET http://example.com/default.asp?phone=12345&message=test HTTP/1.1
and in the Classic ASP page default.asp
you can access the parameters using something like;
<%
Dim phone, message
phone = Request.QueryString("phone")
message = Request.QueryString("message")
%>
Useful Links