Home arrow XML arrow Page 4 - Step by Step to AJAX

Step by Step to AJAX

AJAX has been exciting many programmers as the latest and greatest thing in web development. This article takes a step-by-step look at the Microsoft way to script for AJAX.

Author Info:
By: Jayaram Krishnaswamy
Rating: 4 stars4 stars4 stars4 stars4 stars / 114
November 30, 2005
  1. · Step by Step to AJAX
  2. · Ajax's Model of Interaction
  3. · XmlHttpRequest
  4. · XMLHttpRequest Object Methods
  5. · Fetching a page using AJAX

print this article

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.

current request is stopped
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
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).

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

blog comments powered by Disqus

- Open XML Finally Supported by MS Office
- XML Features Added to Two Systems
- 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

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials