Sign In/My Account | View Cart  
advertisement

Article:
 Very Dynamic Web Interfaces
Subject: I realize that I'm on XML.com, but....
Date: 2005-04-05 17:31:50
From: emdee1
Response to: I realize that I'm on XML.com, but....

> Please don't use XML for such a simple request. Actually, I'm not convinced that XML is the best method for sending any data to JavaScript. I do a lot of work with XMLHTTPRequest, and I simply use the standard JavaScript object literal and array literal notations.


That's great... until you want to reuse the logic for something that isn't JavaScript on the otherside. This is exactly the type of thing that XML is for.


Previous Message Previous Message Move up to Parent Message Up Next Message No Next Message


Titles Only Full Threads Newest First
  • I realize that I'm on XML.com, but....
    2005-04-06 23:06:21 mdchaney [Reply]

    That's great... until you want to reuse the logic for something that isn't JavaScript on the otherside. This is exactly the type of thing that XML is for.


    It's easier to parse the JavaScript object literal notation than it is to parse XML. Also, there are various libraries already available to do so, check www.json.org for more details.


    Given the simplification of using a simple object over using DOM methods to get at your data (again: "response.method" vs. "response.getElementsByTagName('method')[0].firstChild.data") it just seems unlikely that bloating your code and making it unreadable on the JavaScript side in the off chance you'll want to reuse this data elsewhere is the way to go. Particularly given that using DOM methods in any language is likely to be as painful.


Sponsored By: