Windows Scripting
  Home arrow Windows Scripting arrow Page 2 - Handling Live Web Content in WSH - Part 2
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Moblin 
JMSL Numerical Library 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WINDOWS SCRIPTING

Handling Live Web Content in WSH - Part 2
By: Nilpo/Developer Shed Staff Writer
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 4
    2006-12-19

    Table of Contents:
  • Handling Live Web Content in WSH - Part 2
  • Making the Connection
  • Handling the Response
  • Handling Errors and Exceptions
  • Implementing a Workaround
  • Other Uses for XMLHttpRequest

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Handling Live Web Content in WSH - Part 2 - Making the Connection


    (Page 2 of 6 )

    Now that we have our data in order, it’s time to send it to the server.  We’ll begin by connecting to the XMLHttpRequest ActiveX object with a CreateObject() method call to its namespace.  In the last article we used “Microsoft.XMLHTTP” as our namespace.  This time we’ll use a newer version that should be installed on every machine with Internet Explorer 5 or higher.  If you experience errors, just use the older one.

    Set objxmlHTTP = CreateObject(“Msxml2.XMLHTTP”)

    Next we open our connection with the XMLHttpRequest object’s Open() method.  I’ll provide the syntax again for those who need a refresher.

    object.Open(“method”, “URL”[, asyncFlag[, “username”[, “password”]]])

    The first parameter is a text string containing the HTTP method that we wish to use, in our case, “POST.”  The method should be in all caps.  The second parameter is a string containing the form action URL.  The third and final attribute we’ll be using is an optional Boolean value that tells the XMLHttpObject whether or not the data should be sent asynchronously.

    The final two parameters are the username and password, respectively, which we would use if our connection prompted for authentication.  It should be noted that the username and password values will only be sent if requested by the server.

    So continuing on, we open our connection as follows:

    objxmlHTTP.Open(“POST”, actionURL, True)

    objxmlHTTP.setRequestHeader “Content-Type”, _

       “application/x-www-form-urlencoded”

    objxmlHTTP.Send(strPostData)

    We’ve used the XMLHttpRequest object’s setRequestHeader method to tell the server the MIME type of the data we are posting.  This can usually be omitted, but is required by some servers.  We then use the Send() method to send our POST data string by setting it as the parameter.  Syntax for the Send() method is shown below.

    object.Send([“data”])

    More Windows Scripting Articles
    More By Nilpo/Developer Shed Staff Writer


       · After several good discussions and a good response from the first article, I decided...
     

    WINDOWS SCRIPTING ARTICLES

    - Adding Controls to an Application with WPF
    - A Portable Scripting Toolbox
    - WPF Through an Example: Introduction
    - Beginning SharePoint Web Part Development
    - More Alternative Languages for WSH
    - WPF Control Layout
    - WSH in Other Languages
    - Screen Capturing via GDI+ and GDI
    - Understanding Procedures in VBScript
    - Printing Documents in WSH
    - Generating Outlook Signatures Based on Activ...
    - VBScript: Converting and Formatting with Fun...
    - VBScript: Conversion and Format Functions
    - VBScript: Array Functions
    - VBScript: Strings, You Can`t Function withou...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway