Please visit our sponsors !
            
             The HttpRequest object
             
             
             
            The HttpRequest object provides client-side communication with
a server. 
             
             Examples
            readyState 
How to return the state of the document. This property changes as the document
is being loaded. 
            responseText 
How to return the request as a string. 
            status 
How to return the status of the operation, as a code. 
            statusText 
How to return the status of the operation, as a string. 
             
             The HttpRequest object
            With the httpRequest object you can send a request from the client to the
server. 
            If you are using JavaScript in IE 5.0, you can create the httpRequest object
with the following code: 
            
              
                
                  var xmlHTTP = new ActiveXObject("Microsoft.XMLHTTP")
                 | 
               
             
            If you are using VBScript you create the httpRequest object with the
following code: 
            
              
                
                  set xmlHTTP = CreateObject("Microsoft.XMLHTTP")
                 | 
               
             
            The httpRequest object is not a part of the W3C DOM standard. 
             
            Get XML
            How to get an xml file from the server using the httpRequest object. 
            
                  var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP")
xmlHttp.open("GET", "note.xml", false)
xmlHttp.send()
xmlDoc=xmlHttp.responseText |   
            Try it Yourself 
             
            Send XML
            You can also send an xml document to an ASP page on the server, analyze the request, and send back the result. 
            
                  var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP")
xmlHttp.open("POST", "demo_dom_http.asp", false)
xmlHttp.send(xmlDoc)
document.write(xmlHttp.responseText) |   
            The ASP page, written in VBScript: 
            
                  set xmldoc = Server.CreateObject("Microsoft.XMLDOM")
xmldoc.async=false
xmldoc.load(request)
for each x in xmldoc.documentElement.childNodes
   if x.NodeName = "to" then name=x.text
next
response.write(name)
                 |   
            You send the result back to the client using the response.write
property. 
            Try it Yourself 
             
            Important Note
            At the moment, the Microsoft XMLHTTP object can only be run in the BROWSER. 
            SERVER code that attempts to use the XMLHTTP to communicate with other Web
servers, may function incorrectly or perform poorly. 
            This is a bug in the HTTPRequest object. For more information read Microsoft's
Knowledge Base article Q237906. 
            The rumor is that Microsoft will have
this bug fixed in an upcoming release of the XML Library. In the meantime, you
may have to use a commercially available ASPHTTP
component. 
             
            The httpRequest Properties
            
              
                | Property | 
                Description | 
               
              
                | readyState | 
                Returns the state of the document | 
               
              
                | responseBody | 
                Returns the response as an array of unsigned bytes | 
               
              
                | responseStream | 
                Returns the response as an IStream | 
               
              
                | responseText | 
                Returns the response as a string | 
               
              
                | responseXML | 
                Returns the response as an xml document | 
               
              
                | status | 
                Returns the status code as a number | 
               
              
                | statusText | 
                Returns the status as a string | 
               
             
            The httpRequest Methods
            
              
                | Property | 
                Description | 
               
              
                | abort() | 
                Cancel the current http request | 
               
              
                | getAllResponseHeaders() | 
                Returns the value of the http headers | 
               
              
                | getResponseHeader(headerName) | 
                Returns the value of one specified http header | 
               
              
                | open(method, url, async, userid, password) | 
                Opens http request, and specifies the information | 
               
              
                | send() | 
                Send the http request to the server | 
               
              
                | setRequestHeader(headerName,headerValue) | 
                Specifies the name of a http header | 
               
             
             
             
             
             
            
Jump to: Top of Page
or HOME or
             
            Printer friendly page
             
             
            Search W3Schools:
            
             
            What Others Say About Us
            Does the world know about us? Check out these places: 
            
            Dogpile
            Alta Vista
            MSN
            Google
            Excite
            Lycos
            Yahoo
            Ask Jeeves
             
             
            We Help You For Free. You Can Help Us!
            
             
            
W3Schools is for training only. We do not warrant its correctness or its fitness for use.
The risk of using it remains entirely with the user. While using this site, you agree to have read and accepted our
            terms of use and 
            privacy policy. 
            
            Copyright 1999-2002 by Refsnes Data. All Rights Reserved 
             
            
           |