Custom Shopping Cart & eCommerce Merchant Account Integration services

 

Request a Free Quote

Contact Us - Call 1-877-627-2492    


 
Earth Skater Custom eCommerce [Home]
  Authorize.net Certified Developer PayPal Certified Integration CyberSource Certified Developer
      You are here:   Home · Dev Zone · XMLHTTP ASP Code Example      
 
eCommerce Hosting
Affiliate Software
Website Analytics
Merchant Accounts
Merchant Integration

Internet Marketing
Content Management
Custom Development
Custom Web Design

Why Earth Skater
Our Clients
Our Partners
     
 

Author: Staff
EarthSkater.net
This is a small example on using the Microsoft XMLHTTP Control to post form data.

If you are reading this page then I shall assume that you already know a little bit about ASP and running ASP scripts.

Here is the ASP code to post form data from a remote ASP site to a web service / central site using XMLHTTP.  There are many potential uses for this code that EarthSkater can help you develop for your business.

Please feel free to use the code and explanations below to get started.


Copy the following code into a new Active Server Pages (ASP) page called ServerHTTP.asp. Place the ASP page in the default Home directory.
<%
	DataToSend = "id=1"
	dim xmlhttp 
	set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")
	'replace localhost with the server you would like to post to
	xmlhttp.Open "POST","http://localhost/Receiver.asp",false
	'set header to tell the receiving we are posting form data
	xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
	xmlhttp.send DataToSend		'send data in the form of a query string
	Response.ContentType = "text/xml"		'*note what this does
	Response.Write xmlhttp.responsexml.xml		'return response from home database
        Set xmlhttp = nothing
%>

NOTE: The two ASP pages 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.


Copy the following code into a new ASP page called Receiver.asp.
Place the ASP page in the default Home directory.

<%
	value = Request.Form("id")
	Response.ContentType = "text/xml"	'* note what this does
	response.write "<ReturnValue>" & value & "</ReturnValue>"
%>

Run ServerHTTP.asp asp page to post data to receiver.asp which will then simply output the data for display.  These two asp pages should be placed on different domains or within different IIS virtual directories.  Overall this is a great example in how web services can be accomplished through ASP.

Run this code sample
 

 

Home | eCommerce Shopping Cart | Affiliate Software | Website Analytics | eCommerce Merchant Accounts | Merchant Account Integration

Help & Support | Contact | Request a Quote | Affiliates | Developer Articles | Marketing Articles | Blog | Policies | Site Map

© 2008

Earth Skater  Boca Raton Web Design Florida FL USA  

Content last updated 7/30/2008