Problem with using POST method with XMLHTTP
How could I use POST method to transfer parameters with XMLHTTP?
With GET all works correct, but with POST I get a problem.
client.asp with GET - all works
<head>
<title> XMLHTTP Example </title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<%
dim objXMLHTTP
set objXMLHTTP = Server.CreateObject("Microsoft.XMLHTTP")
objXMLHTTP.Open "GET", "http://localhost/test/server.asp?fName=Mitchell", false
objXMLHTTP.Send
Response.Write(objXMLHTTP.responseText)
set objXMLHTTP = nothing
%>
</body>
</html>
client2.asp with POST - doesn't works
<head>
<title> XMLHTTP Example </title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<%
dim objXMLHTTP
set objXMLHTTP = Server.CreateObject("Microsoft.XMLHTTP")
objXMLHTTP.Open "POST", "http://localhost/test/server.asp", false
objXMLHTTP.Send("fName=Mitchell")
Response.Write(objXMLHTTP.responseText)
set objXMLHTTP = nothing
%>
</body>
</html>
server.asp
<%
dim fName
if Request.ServerVariables("HTTP_METHOD") = "GET" then
fName = Request.QueryString("fName")
elseif Request.ServerVariables("HTTP_METHOD") = "POST" then
fName = Request.Form("fName")
end if
Response.Write "<Name_Details>"
Response.Write "<TheName>"
Select Case fName
Case "Mitchell"
Response.Write fName & " Harper"
Case "John"
Response.Write fName & " Doe"
Case "Harry"
Response.Write fName & " Potter"
Case Else
Response.Write "[Unknown]"
End Select
Response.Write "</TheName>"
Response.Write "</Name_Details>"
%>
|