Sign In/My Account | View Cart  
advertisement

Article:
 Very Dynamic Web Interfaces
Subject: DOM 3 & simplification
Date: 2005-02-14 05:45:48
From: JimDabell

Er, DOM 3 Load and Save isn't a "proposed specification". It was released as a Recommendation in April 2004 and has been implemented by multiple browsers already. It's never going to be as well-supported as XMLHttpRequest because, hey, Internet Explorer. that doesn't mean it isn't a stable, deployed specification though.


You can simplify the instantiation of the XMLHttpRequest object by simply including a little bit of generic Javascript before you use the native object method:


if (typeof XMLHttpRequest != "object") {
function XMLHttpRequest() {
return new ActiveXObject("Microsoft.XMLHTTP");
}
}


That way you can simply call new XMLHttpRequest() for Internet Explorer in the same way that you do for all the other browsers.


Previous Message Previous Message   Next Message Next Message


Titles Only Titles Only Newest First
  • DOM 3 & simplification
    2005-02-28 09:45:56 Lars Huttar [Reply]

    Thanks for this helpful tip. Especially good to know that XMLHttpRequest is part of a public standard.


    But you still have to do branching code when you *use* the XMLHttpRequest object, right? E.g. looking at the sample code in the article, req.send() apparently takes no argument in IE but takes a "null" argument in other browsers?


    I guess you could handle this by writing more js helper functions.

    • DOM 3 & simplification
      2005-03-04 02:34:59 JimDabell [Reply]

      Actually, I take back what I said about DOM3LS. The "load" part of DOM3LS was present in drafts, but didn't make it to the final recommendation. Mozilla's documentation still lists it as part of DOM3LS though, and Gecko/KHTML/Opera all implement it according to the draft description.


      https://bugzilla.mozilla.org/show_bug.cgi?id=284737



      While the MSDN documentation remains ambiguous with respect to what happens when you pass null for the request body, I haven't found any problem with doing so in practice.


      http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/xmmthsendixmlhttprequest.asp





Sponsored By: