Re: Using XMLHttpRequest in Firefox



Martin Honnen wrote:
> Trevor L. wrote:
>
>> I pulled the example below from w3schools and made a few cosmetic
>> changes
>
>> if (window.XMLHttpRequest) // NOTE: THIS PATH DOES NOT WORK IN
>> FIREFOX { alert('XMLHttpRequest')
>> xmlhttp = new XMLHttpRequest()
>> if (document.onreadystatechange)
>> xmlhttp.onreadystatechange = state_Change
>> else
>> alert ('document.onreadystatechange not found') // NOTE:
>> THIS ALERT DISPLAYS IN FIREFOX
>
> I don't know the original script but if that if/else is one of your
> "cosmetical changes" then throw it out, it is crap, you need to set
> onreadystatechange on the request object whether that is MSXML or
> Mozilla or any other implementation and you want to do asynchronous
> requests. And document.onreadystatechange does not matter in any way
> for XMLHttpRequest.
>
> See
> <http://www.faqts.com/knowledge_base/view.phtml/aid/6826/fid/616>
> for code that works and has much less code forks, creation of the
> request object is all that is different.

Yes, I put in the if else.
Originally there was no 'if'. By putting in the 'else' I determined that
this was the point where it failed.
Because it failed here, it seems to indicate that onreadystatechange is not
a valid Firefox construct. Am I wrong ?

I have been looking at the reference, and I will try to use it, but if
onreadystatechange fails in Firefox, I can't see how it will work. Do I just
*not* use it in Firefox?

Am I not doing asynchronous requests?
If not, what did I do wrong?
--
Cheers,
Trevor L.
Website: http://tandcl.homemail.com.au


.



Relevant Pages

  • Re: Javascript doesnt work in Firefox
    ... Trevor L. wrote: ... After some experimentation using both IE6 and FF, I now have Firefox (and ... IE6) working OK. ... title = cap ...
    (microsoft.public.scripting.jscript)
  • Re: Forecastfox and W2k
    ... Pro machine from the Firefox Add-ons page but after pressing the 'Install Now for Windows' I receive a message at the top of the browser saying: ... Thanks Trevor... ...
    (uk.comp.homebuilt)
  • Re: XHR, responseXML and this
    ... the function assigned to onreadystatechange as the 'this' object. ... i did a quick test with Firefox 3.0.b4 it works with this ... using the 'this' object in the onreadystatechange handler does not work ... then, I'll stay with req:o ...
    (comp.lang.javascript)
  • Re: OT browser hi-jacking
    ... Trevor Best wrote: ... whether Firefox or the URL is at fault. ... re-install it? ... This may solve some crash problems which ...
    (uk.comp.homebuilt)
  • Re: Browsers browsers
    ... Trevor L. wrote: ... When I downloaded and used Firefox, I found it does things differently. ... I am having problems with some code which displays my sitemap. ... [hate IE and its non standard code ...
    (microsoft.public.scripting.jscript)