AJAX works in IE6 but not IE7 or Firefox

Discussion in 'Javascript' started by Steve Wright, Mar 13, 2007.

  1. Steve Wright

    Steve Wright Guest

    I have an AJAX routine on a webpage that is working in IE6, but not IE7
    or Firefox v2.0.0.2

    The webpage is

    http://www.a-drop-in-the-ocean.co.uk/CWS/monitor10bins.php?quarry=401

    The AJAX routine is encapsulated in the module

    http://www.a-drop-in-the-ocean.co.uk/CWS/js/timer.js

    What it is supposed to do is every ten seconds, read the contents of the
    file http://www.a-drop-in-the-ocean.co.uk/CWS/401/seqno.txt. This file
    just contains the number 46955. If this number changes then the page
    will refresh.

    The timer routine, counts down the 10 seconds, displaying the counter in
    the top right hand corner. Once the counter hits zero, it triggers the
    AJAX request.

    The onload event also triggers the AJAX request to get the initial value
    of the number.

    I presume that IE7 and FF use the XMLHttpRequest() function and that I
    must have coded this incorrectly. But what is wrong with it?

    Interestingly, the firebug extension in FF, shows the request and
    response headers along with the response 46955.

    Fixing this is not critical at the moment as IE6 is our company
    standard. But at some stage we will migrate to IE7...

    Has anybody got any ideas?
    --
    Steve Wright
    Steve Wright, Mar 13, 2007
    #1
    1. Advertising

  2. Steve Wright

    Jeremy Guest

    Steve Wright wrote:
    > I have an AJAX routine on a webpage that is working in IE6, but not IE7
    > or Firefox v2.0.0.2
    >
    > The webpage is
    >
    > http://www.a-drop-in-the-ocean.co.uk/CWS/monitor10bins.php?quarry=401
    >
    > The AJAX routine is encapsulated in the module
    >
    > http://www.a-drop-in-the-ocean.co.uk/CWS/js/timer.js
    >
    > What it is supposed to do is every ten seconds, read the contents of the
    > file http://www.a-drop-in-the-ocean.co.uk/CWS/401/seqno.txt. This file
    > just contains the number 46955. If this number changes then the page
    > will refresh.
    >
    > The timer routine, counts down the 10 seconds, displaying the counter in
    > the top right hand corner. Once the counter hits zero, it triggers the
    > AJAX request.
    >
    > The onload event also triggers the AJAX request to get the initial value
    > of the number.
    >
    > I presume that IE7 and FF use the XMLHttpRequest() function and that I
    > must have coded this incorrectly. But what is wrong with it?
    >
    > Interestingly, the firebug extension in FF, shows the request and
    > response headers along with the response 46955.
    >
    > Fixing this is not critical at the moment as IE6 is our company
    > standard. But at some stage we will migrate to IE7...
    >
    > Has anybody got any ideas?


    What is not working about it? The AJAX code looks like it should work
    in both firefox and IE, so I don't think that's your problem.

    I would guess off the top of my head that the response is getting cached
    (despite sending if-modified-since) and so you're not getting back an
    updated response. There are a lot of ways to prevent this, such as
    using a POST request instead of GET and/or appending a randomized query
    string.

    Jeremy
    Jeremy, Mar 13, 2007
    #2
    1. Advertising

  3. Steve Wright

    Erwin Moller Guest

    Steve Wright wrote:

    > I have an AJAX routine on a webpage that is working in IE6, but not IE7
    > or Firefox v2.0.0.2
    >
    > The webpage is
    >
    > http://www.a-drop-in-the-ocean.co.uk/CWS/monitor10bins.php?quarry=401
    >
    > The AJAX routine is encapsulated in the module
    >
    > http://www.a-drop-in-the-ocean.co.uk/CWS/js/timer.js
    >
    > What it is supposed to do is every ten seconds, read the contents of the
    > file http://www.a-drop-in-the-ocean.co.uk/CWS/401/seqno.txt. This file
    > just contains the number 46955. If this number changes then the page
    > will refresh.
    >
    > The timer routine, counts down the 10 seconds, displaying the counter in
    > the top right hand corner. Once the counter hits zero, it triggers the
    > AJAX request.
    >
    > The onload event also triggers the AJAX request to get the initial value
    > of the number.
    >
    > I presume that IE7 and FF use the XMLHttpRequest() function and that I
    > must have coded this incorrectly. But what is wrong with it?
    >
    > Interestingly, the firebug extension in FF, shows the request and
    > response headers along with the response 46955.
    >
    > Fixing this is not critical at the moment as IE6 is our company
    > standard. But at some stage we will migrate to IE7...
    >
    > Has anybody got any ideas?


    Hi,

    go to: www.w3schools.com

    Follow the AJAX link.
    Read through it. It won't take more than 15 minutes if you are familiar with
    JS.
    You will find a nice routine at the end that gives you your xmlhttprequest
    on all platforms that support it.

    Regards,
    Erwin Moller

    PS: Shame your company isn't migrating to FF.
    Erwin Moller, Mar 13, 2007
    #3
  4. Steve Wright

    Bart Lateur Guest

    Steve Wright wrote:

    >Has anybody got any ideas?


    Your request.open call only has 2 parameters,

    request.open ('get', url);

    the docs for XMLHttpRequest for Mozilla/Firefox say it needs 3 -- and
    last time I chaked, Firefox does indeed need the 3rd parameter.

    req.open('GET', 'http://www.mozilla.org/', false);

    <http://developer.mozilla.org/en/docs/XMLHttpRequest>

    HTH

    --
    Bart.
    Bart Lateur, Mar 14, 2007
    #4
  5. Steve Wright

    Steve Wright Guest

    On Mar 14, 7:06 pm, Bart Lateur <> wrote:
    > Steve Wright wrote:
    > >Has anybody got any ideas?

    >
    > Your request.open call only has 2 parameters,
    >
    > request.open ('get', url);
    >
    > the docs for XMLHttpRequest for Mozilla/Firefox say it needs 3 -- and
    > last time I checked, Firefox does indeed need the 3rd parameter.
    >
    > req.open('GET', 'http://www.mozilla.org/', false);
    >
    > <http://developer.mozilla.org/en/docs/XMLHttpRequest>


    Whilst you are correct, that is not the root cause of the problem.

    I have changed the request.open to pass true as the 3rd parameter, but
    this has no effect in Firefox.

    (Please note I am trying this at work, so I haven't changed the
    version I posted to the group yet - I'll do that tonight).

    My next idea is to rewrite using the prototype library routines (if I
    can get my head around them)
    Steve Wright, Mar 15, 2007
    #5
  6. Steve Wright

    Bart Lateur Guest

    Steve Wright wrote:

    >> req.open('GET', 'http://www.mozilla.org/', false);
    >>
    >> <http://developer.mozilla.org/en/docs/XMLHttpRequest>

    >
    >Whilst you are correct, that is not the root cause of the problem.
    >
    >I have changed the request.open to pass true as the 3rd parameter, but
    >this has no effect in Firefox.


    While that may be true, in my haste, I got the value of the parameter
    wrong. It is false for synchronous, and true for asynchronous mode. As a
    note on the page says:

    Note: This example works synchronously, so it will block the
    user interface if you call this from your JavaScript. You should
    not use this in practice.

    --
    Bart.
    Bart Lateur, Mar 15, 2007
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Aidan
    Replies:
    4
    Views:
    496
    Neredbojias
    Jun 7, 2007
  2. OccasionalFlyer

    Page shows in FIrefox, IE7 but not IE6

    OccasionalFlyer, Dec 4, 2008, in forum: HTML
    Replies:
    4
    Views:
    430
    Chaddy2222
    Dec 5, 2008
  3. APA
    Replies:
    0
    Views:
    1,248
  4. Manfred

    Script works with IE6 but not with IE7

    Manfred, Feb 5, 2007, in forum: Javascript
    Replies:
    3
    Views:
    90
    Manfred
    Feb 7, 2007
  5. Terry
    Replies:
    1
    Views:
    110
    Terry
    Oct 20, 2007
Loading...

Share This Page