XML
  Home arrow XML arrow Page 4 - Step by Step to AJAX
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
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? 
XML

Step by Step to AJAX
By: Jayaram Krishnaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 61
    2005-11-30

    Table of Contents:
  • Step by Step to AJAX
  • Ajax's Model of Interaction
  • XmlHttpRequest
  • XMLHttpRequest Object Methods
  • Fetching a page using AJAX

  • 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


    Step by Step to AJAX - XMLHttpRequest Object Methods


    (Page 4 of 5 )

    This short list of methods is shared by all supported browsers. In this tutorial we shall look at some of the highlighted methods.

    abort()
    current request is stopped
    getAllResponseHeaders()
    returns a string containing information of headers
    getResponseHeader ("headerlabel")
    returns a string containing information about a single header
    open("method", "URL"[,asyncFlag[,"userName"[,"password"]]])
    assigns various request attributes
    send(content)
    Transmits the data with information that may be posted, if needed
    setRequestHeader ("label", "value")
    assigns label, value pair for the header

    While open() and send() are most often used, the others are also useful in some cases. The open() method begins the interaction and takes two mandatory arguments; the "method" used to open, which is either GET or POST, and the URL to which the request is made.

    The GET and POST methods are similar to those used in ASP, as some of you might recognize. The GET is indicated for retrieving read only data while POST is for sending data to the server.

    The URL could be complete, or a relative URL.

    The third parameter which is optional (default value TRUE being asynchronous) sets the interaction to be synchronous (FALSE) or asynchronous (TRUE). If you choose the synchronous route, the script waits for the response to arrive before acting. The useful mode is to set the interaction to be asynchronous and use the  onreadystatechange event (to be discussed) to get at the response.

    XMLHttpRequest Object Properties

    The following read only properties are browser agnostic (all supported browsers understand them).

    onreadystatechange
    Event handler which fires every time the state changes
    readState
    Integer representing the status of the object
    0 = uninitialized
    1 = loading
    2 = loaded
    3 = interactive
    4 = complete
    responseText
    Data returned in string format
    responseXML
    Data returned in DOM Compatible format
    status
    Numeric code returned by server indicating status
    404: Not found
    200: OK
    statusText
    Message string that came with the status

    More XML Articles
    More By Jayaram Krishnaswamy


       · XML is a true advance in the internet technology and its usefulness and flexibility...
       · I think you should begin an article such as this one, which aims to educate the...
     

    XML ARTICLES

    - Using Regions with XSL Formatting Objects
    - Using XSL Formatting Objects
    - More Schematron Features
    - Schematron Patterns and Validation
    - Using Schematron
    - Datatypes and More in RELAX NG
    - Providing Options in RELAX NG
    - An Introduction to RELAX NG
    - Path, Predicates, and XQuery
    - Using Predicates with XQuery
    - Navigating Input Documents Using Paths
    - XML Basics
    - Introduction to XPath
    - Simple Web Syndication with RSS 2.0
    - Java UI Design with an IDE







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek