SunQuest
 
       XML
  Home arrow XML arrow Page 3 - XML in the Browser: Submitting forms using...
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  
Dedicated Servers  
Actuate Whitepapers 
VeriSign Whitepapers 
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? 
XML

XML in the Browser: Submitting forms using AJAX
By: Chris Root
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 162
    2005-04-25

    Table of Contents:
  • XML in the Browser: Submitting forms using AJAX
  • What's Out There Now
  • The XML in HTTPRequest
  • HTTP Methods
  • Using POST
  • Submitting a Form

  • 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

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    XML in the Browser: Submitting forms using AJAX - The XML in HTTPRequest


    (Page 3 of 6 )

     

    Though this object has XML in its name, it doesn't necessarily have to use XML. If you wish to use it in an entirely cross platform way, however, consider that currently Apple's Safari requires that the response from the server be of the text/xml mimetype.

     

    This may or may not impact your application design. It isn't hard to set up an XML formatted response and code to use the XML data once it's received, but if you were planning on sending text strings only back and forth, this is something to consider. It's likely that the next version of Safari will not have this problem, and working around it is nothing compared to most cross browser DHTML problems. Sending information as a string, on the other hand, works in all platforms and browsers that support the request object.

     

    The fact that the request object supports XML allows it to be the gateway for a number of XML based message formats, such as SOAP and XMLRPC, or your own custom solutions. Because the request object uses HTTP, you could also use it with WEBDAV if you were so inclined. If you are only retrieving XML from the server and not sending anything, you can even use AJAX without a server side application platform. The implementation details are up to you, but the tools are there.

     

    The Event Handler

     

    Whatever event handler function you specify should check for two things. The first is the readyState property. If readyState is 4, then the response has been completely recieved. You then need to check the status property of the request object to determine whether the request was successful. If the value of status is 200, any data that was sent back as a response is ready for use. If status is something other than 200, you will be able to display the error by using the statusText property.

     

    The response, as mentioned before, can be a simple text string or an XML document DOM (Document Object Model). The two request object response properties you will use for working with a response are responseText and responseXML. The DOM object stored in responseXML is a completely accessible DOM that can be manipulated and traversed in the same way that your HTML document can be. The responseText property is used when a simple text string is sent by the server.

     

    Accessing the XML file through the usual limited DOM methods provided for HTML is no fun. The European Computer Manufacturers Association, or ECMA, who is responsible for the ECMA script standard on which Javascript is based, has just introduced a new extension to ECMA called E4X which is especially designed to work with XML documents. E4X includes support for XPath, which is a W3C recommendation for addressing information within an XML document. Currently, there are no browsers that support E4X. The first browser to support it will be Firefox 1.1. Unfortunately, until E4X truly arrives, traditional DOM methods are all we have.

     

    More XML Articles
    More By Chris Root


       · this is just what I was looking for, but I found a few error's or something what...
       · I was using XMLHttpRequest from javascript through hidden frames to get/put to the...
       · The permissions error is caused by trying to run that script off of your own...
       · Hi,I am able to send the request to the server. But the problem is I dont know how...
       · It would be handled as any http request would be. I don't do a lot of JSP but I...
       · I almost forgot. JSP has a Request object for recieving the request. The...
       · Hi: How can i upload a file using the ajax form method ??? thanks for your...
       · You mention in XML in the Browser: Submitting forms using AJAX - HTTP Methods...
       · request = new ActiveXObject("Microsoft.XMLHTTP"); request.onreadystatechange =...
       · You're current script does not support radio buttons. The POST/GET will return the...
       · Great tutorial,i've used this script, and i found that it doesn't preserve special...
       · The W3C specifications state that any form object that is disabled cannot be...
       · Hi, the radio part of the last post is not working for me. I'm getting a Javascript...
       · I'm having the same problem.. Any solutions? Thanks!
       · Hello,This is how I made the radio button case work correctly in IE 6 sp2....
       · Sorry about that, as I said, I never tried out all the types. Thanks for pointing it...
       · I have done some testing and have found multiple selects don't work correctly...
       · But where is the displayState function that is needed to get the values returned...
       · That would be your AJAX script which this article does not address. Whatever you are...
       · At least as far as i know...Please correct me if I'm wrong.
       · Hmm this new GetFormValues function made my code stop working..Not sure why at...
       · Ahh got it working..Thanks heaps for your code. Much appreciated, saved me lots...
       · Hello,Could you please send a link to the complete script.Thanx in...
       · My changed version with testing html...
     

    XML ARTICLES

    - 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
    - UI Design with Java and XML Toolkits
    - Displaying ADO Retrieved Data with XML Islan...
    - Widget Walkthrough
    - Introduction to Widgets
    - The Why and How of XML Data Islands
    - Creating an XUL App Installer
    - Overlays in XUL
    - Skinning Your Custom XUL Applications







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