XML Tutorials
  Home arrow XML Tutorials arrow Page 3 - Handling XML Data for Ajax
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Forums Sitemap 
Download TestComplete 
JMSL Numerical Library 
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 TUTORIALS

Handling XML Data for Ajax
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-01-03

    Table of Contents:
  • Handling XML Data for Ajax
  • Back on the Client: Mining the XML
  • XML Parsing with JavaScript
  • Populating the Form on a Microsoft Browser
  • Populating the Form on Other Browsers

  • 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 XML Data for Ajax - XML Parsing with JavaScript


    (Page 3 of 5 )

    Remember, it all starts with our callback() function in JavaScript:

      function callback() {
          if (req.readyState==4) {
              if (req.status == 200) {
                 
    if (window.XMLHttpRequest) {
                     
    nonMSPopulate();
                  }
                  else if (window.ActiveXObject) {
                      
    msPopulate();
                 
    }
             
    }
             
    clear();
          
    }
      }

    Remember howconvertToXML()had to determine whether the browser was Internet Explorer or something else? We have the same problem again here. Whencallback()is invoked, it must check to see whether we are runningActiveXObject(Internet Explorer) orXMLHttpRequest(all other major browsers).

    If the browser is Internet Explorer, we runmsPopulate()to strip out the data from the XML. Otherwise, we runnonMSPopulate(). What's the difference? It has to do with how we get an XML parser and with the API that parser presents to us. Firefox, Mozilla, and Safari all usenew DOMParser()to get a built-in parser that can parse XML, and it's rumored that Opera will support this soon. Internet Explorer, on the other hand, usesnew ActiveXObject("Microsoft.XMLDOM")to get the Microsoft XML parser.

    Although Ajax works on most browsers in their current released states, it's entirely fair to say that the problem of cross-browser compatibility is the Achilles' heel of web applications.

    More XML Tutorials Articles
    More By O'Reilly Media


       · This article is an excerpt from the book "Ajax on Java," published by O'Reilly. We...
     

    Buy this book now. This article is excerpted from chapter four of the book Ajax on Java, written by Steven Douglas Olson (O'Reilly, 2007; ISBN: 0596101872). Check it out today at your favorite bookstore. Buy this book now.

    XML TUTORIALS ARTICLES

    - Creating RSS 2.0 Feeds
    - Using Modules in Your RSS Feed
    - RSS 2.0
    - Querying XML: Use Cases
    - Joins and Query Use with XML
    - Solving Problems by Querying XML
    - Performing Set Operations When Querying XML
    - Querying XML
    - Handling Data for Ajax with JSON
    - Handling XML Data for Ajax
    - XML and JSON for Ajax





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT