Home arrow XML arrow Page 2 - XML in the Browser: Submitting forms using AJAX

XML in the Browser: Submitting forms using AJAX

One of the least user friendly features of most websites is forms. The longer the form, the more annoying it gets. However, a new technology called AJAX (that has nothing to do with household cleansers!) can help.

Author Info:
By: Chris Root
Rating: 4 stars4 stars4 stars4 stars4 stars / 211
April 25, 2005
  1. · XML in the Browser: Submitting forms using AJAX
  2. · What's Out There Now
  3. · The XML in HTTPRequest
  4. · HTTP Methods
  5. · Using POST
  6. · Submitting a Form

print this article

XML in the Browser: Submitting forms using AJAX - What's Out There Now
(Page 2 of 6 )


Both Google and Amazon have been pioneers in developing AJAX applications. Google's GMail, Suggest, and Google Maps all use AJAX in one way or another to make the Web user interface more like a desktop application.


The documentation for the request object is a little slim, and assumes a certain amount of knowledge of at least HTTP in order to get the most out of it. This article will attempt to lay out as many specifics about the use of XMLHTTPRequest as possible to enable you to use it to its full potential, with a focus on how to use it with forms.


The Basics


The request object (as we will try to call it from now on) is a special Javascript object that can be used in the same way that many such objects can be used. The only difference in implementation is in Microsoft Internet Explorer. In Explorer the request object is an Active X control. A simple example of how to deal with this difference is below.


var doc = null

   if (typeof window.ActiveXObject != 'undefined' )


       doc = new ActiveXObject("Microsoft.XMLHTTP");

       doc.onreadystatechange = displayState;




       doc = new XMLHttpRequest();

       doc.onload = displayState;



If we are using IE, an instance of the Active X object is created and the onreadystatechange event is attached to it. If, however, it is just a plain old Javascript object, we create an instance of it and attach the onload event.


A function called displayState is called when the readystate changes or, in the case of the non-Active X object, the onload event is fired. Aside from these differences, everything is cross browser compatible. Except for one thing.


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-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials