Andrew Warner

Navigation

Skip navigation.

Search

Site navigation

Email conversation

FromAndrew Warner
ToMe
Subjectxml importing script: why MWJ_ldD array for XMLHttpRequest ?
Date3 May 2005 19:44
Hi,

I am playing around with your importxml.js script and
wanted to know the reason that importXML() "pushes"
each newly created XMLHttpRequest object to the global
array MWJ_ldD.  


thanks,

Andrew
FromMe
ToAndrew Warner
SubjectRe: xml importing script: why MWJ_ldD array for XMLHttpRequest ?
Date4 May 2005 09:38
Andrew,

> I am playing around with your importxml.js script and
> wanted to know the reason that importXML() "pushes"
> each newly created XMLHttpRequest object to the global
> array MWJ_ldD.  

The global array serves two purposes.

1. For older browsers like Opera 7.5- and Internet Explorer on Mac that use
the iframe, it is a reference to the individual iframe. The MWJ_checkXMLLoad
function then continually checks the contents of the array asynchronously to
see if any of the iframes have loaded. If so, it runs their handler
function.

2. For browsers that can natively import XML (Opera 7.6+, Safari 1.2+,
Internet Explorer 5+ and Mozilla/Firefox), the array stores a reference to
the individual XML importing objects. The array index is then used by the
onreadystatechange handler function to reference the object. In theory, I
could use the 'this' keyword instead for most handler functions, but as the
comment says, browsers do not all correctly create the reference in the
onreadystatechange handler function:
"note: in XML importing event handlers, 'this' refers to window"
This was simply a simple workaround for that problem (one of several
possibilities, such as using target and srcElement - but I already had the
array for use with iframes, so I decided to re-use it).


Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.