How to Submit Form Data by Using Xmlhttp Or ServerXMLHTTP Object

xiaoxiao2021-03-06  40

How to Submit Form Data by Using Xmlhttp Or ServerXMLHTTP Object

Article ID: 290591last Review: July 13, 2004Revision: 1.0

This Article Was previously Published Under Q290591

On this Page

Summarymore informationReferences

Summary

In Some Cases, You May Want To Send Data TO A Port Or Server So That You Can Use That

Form Collection on The

Request Object In The Page or Listening Application. To do this

Form collection.

More information

Requests That Are Being Sent Are Based on Two Parts: The

HEADER AND THE

Body. The

Header Contains Information About the

Body So ​​That The Receiver Knows What data is contained there.

Header InformationThe Header Information That Needs to Be Set Is The

Content-Type. In this case, set this to the value of

Application / X-WWW-FORM-URLENCODED.

Body DataThe

Body Contains The Data That You Want to Send. The Data Takes The Shape of

Name =

Value. for multiple values, you can use the "&" Symbol to Separate Each Name-Value Pair. for Example:

INPUT1 = Hello & INPUT2 = World & IdValue = 12345

The Receiver Is Able To Pick The VALUES "Hello" "" "" and "12345" by using the name "INPUT1," INPUT2, "AND" iDValue "Respectively.

Step-by-step instruction for Serverxmlhttp Object

1.Ensure that the server has MSXML 3.0 or later parser, that the Proxy Configuration Utility has been run, and that the settings have been configured. For more information, see the "References" section of this article.2.Copy the following code INTO A New Active Server Pages (ASP) Page Called ServerHttp.asp. Place The ASP Page In The Default Home Directory. <% @ language = VBScript%> <%

DataSend = "ID = 1"

DIM XMLHTTP

SET XMLHTTP = Server.createObject ("msxml2.serverxmlhttp")

XMLHTTP.Open "Post", "http://localhost/receiver.asp", false

XMLHTTP.SetRequestHeader "Content-Type", "Application / X-WWW-FORM-URLENCODED"

Xmlhttp.send DataSend

Response.contentType = "text / xml"

Response.write Xmlhttp.Responsexml.xml

SET XMLHTTP = Nothing

%> NOTE: The two ASPs should be in different virtual folders due to threading issues.If pooling is set to Low or Medium (this is the default for Microsoft Windows 2000), you should POST to an ASP in a different virtual folder If. the ASP is in the same virtual folder, the ASP stops responding (hangs). After you close the browser, that ASP and other ASPs continue to hang because the request stays queued even though you close the browser. you must restart IIS or restart the computer.If you change the pooling to High, you can run the code to the remote ASP again because you are using a new thread. 3.Copy the following code into a new ASP page called Receiver.asp. Place the ASP page in the Default Home Directory. <% @ language = vbscript%>

<%

Value = Request.form ("ID")

Response.contentType = "text / xml"

Response.write "" & Value & ""%>

When Posting, be sure that you use the name of the server, not Localhost, and that the URL that is being opened by the XMLHttp, should also contain the same server name. 4.Ensure that the "POST" is pointing to the correct Location.5.click the submit xmlhttp button.when you use just the

XMLHTTP Object from Clom Clom Clom Clom Cliant-Side Script, The Same Header Information and Data Format Must Be Observed.

Step-by-step instruction for XMLHTTP Object

1.copy The Following Code Into A New ASP Page Called ClientHttp.asp. Place The ASP Page In The Default Home Directory.