SetTimeout not working with IE

Discussion in 'Javascript' started by Shan, Feb 22, 2008.

  1. Shan

    Shan Guest

    Hi...

    I am trying to get progress of a backend task, which is initiated from
    web gui....
    To achieve it i am using Ajax. To get recent progress of backend task,
    i am calling the same Ajax function using setTimeOut after some x
    seconds.

    This logic is working very fine in Firefox, Safari. But when i tested
    my application in IE. It seems like the setTimeOut function is not
    considering the second argument in it.

    Ajax function is called frequently, irrespective of secong argument to
    setTimeout("fn()",5000)


    What may be the problem....?



    Advance thanks for any help.

    Regards,
    Shan
    Shan, Feb 22, 2008
    #1
    1. Advertising

  2. Shan

    David Mark Guest

    On Feb 22, 3:10 am, Shan <> wrote:
    > Hi...
    >
    > I am trying to get progress of a backend task, which is initiated from
    > web gui....
    > To achieve it i am using Ajax. To get recent progress of backend task,
    > i am calling the same Ajax function using setTimeOut after some x
    > seconds.
    >
    > This logic is working very fine in Firefox, Safari. But when i tested
    > my application in IE. It seems like the setTimeOut function is not
    > considering the second argument in it.


    In this case, things are not as they seem. The setTimeout method
    works as expected in IE.

    >
    > Ajax function is called frequently, irrespective of secong argument to
    > setTimeout("fn()",5000)


    Though it isn't the problem at hand, I recommend you change that to:

    window.setTimeout(fn, 5000);

    Passing a string to setTimeout to be evaluated is virtually never a
    good idea. It seems particularly silly in this case. If you need to
    support ancient browsers that cannot handle a function passed to
    setTimeout, see the FAQ notes.

    >
    > What may be the problem....?


    Can't tell from here. Post some code.
    David Mark, Feb 22, 2008
    #2
    1. Advertising

  3. Shan

    Shan Guest

    Thanks.
    I fixed the problem. The reason is Ajax response Cached by IE.
    So i didnt get the proper progress info.
    To overcome the problem i have used post method over Ajax request.


    On Feb 22, 1:18 pm, David Mark <> wrote:
    > On Feb 22, 3:10 am, Shan <> wrote:
    >
    > > Hi...

    >
    > > I am trying to get progress of a backend task, which is initiated from
    > > web gui....
    > > To achieve it i am using Ajax. To get recent progress of backend task,
    > > i am calling the same Ajax function using setTimeOut after some x
    > > seconds.

    >
    > > This logic is working very fine in Firefox, Safari. But when i tested
    > > my application in IE. It seems like the setTimeOut function is not
    > > considering the second argument in it.

    >
    > In this case, things are not as they seem. The setTimeout method
    > works as expected in IE.
    >
    >
    >
    > > Ajax function is called frequently, irrespective of secong argument to
    > > setTimeout("fn()",5000)

    >
    > Though it isn't the problem at hand, I recommend you change that to:
    >
    > window.setTimeout(fn, 5000);
    >
    > Passing a string to setTimeout to be evaluated is virtually never a
    > good idea. It seems particularly silly in this case. If you need to
    > support ancient browsers that cannot handle a function passed to
    > setTimeout, see the FAQ notes.
    >
    >
    >
    > > What may be the problem....?

    >
    > Can't tell from here. Post some code.
    Shan, Feb 22, 2008
    #3
  4. Shan

    David Mark Guest

    On Feb 22, 8:34 am, Shan <> wrote:
    > Thanks.


    You're welcome. Please don't top-post.

    > I fixed the problem. The reason is Ajax response Cached by IE.
    > So i didnt get the proper progress info.
    > To overcome the problem i have used post method over Ajax request.


    That is one way to do it, but it is an end-around.

    You might try something like this instead:

    xmlhttp.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 1990
    00:00:00 GMT');
    xmlhttp.setRequestHeader('Cache-Control', 'no-cache');

    [snip]
    David Mark, Feb 22, 2008
    #4
  5. David Mark wrote:
    > On Feb 22, 3:10 am, Shan <> wrote:
    >> Ajax function is called frequently, irrespective of secong argument to
    >> setTimeout("fn()",5000)

    >
    > Though it isn't the problem at hand, I recommend you change that to:
    >
    > window.setTimeout(fn, 5000);
    >
    > Passing a string to setTimeout to be evaluated is virtually never a
    > good idea. It seems particularly silly in this case. If you need to
    > support ancient browsers that cannot handle a function passed to
    > setTimeout, see the FAQ notes.


    That's an exaggeration and a non sequitur. That it requires older browsers
    for the use of a Function object reference to make sense has nothing to do
    with the age of those user agents as we are talking about a proprietary
    method of a host object, as you were so kind (and correct) to emphasize by
    recommending to use `window' as base reference of the property access.

    There is no need to use Function object references *here*, and I consider it
    harmful, at the least unwise, to do so *in this case*.


    PointedEars
    --
    realism: HTML 4.01 Strict
    evangelism: XHTML 1.0 Strict
    madness: XHTML 1.1 as application/xhtml+xml
    -- Bjoern Hoehrmann
    Thomas 'PointedEars' Lahn, Feb 24, 2008
    #5
    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. =?Utf-8?B?RQ==?=

    javascript setTimeout does not work

    =?Utf-8?B?RQ==?=, May 2, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    8,756
    =?UTF-8?B?R8O2cmFuIEFuZGVyc3Nvbg==?=
    May 2, 2006
  2. tshad
    Replies:
    4
    Views:
    157
    tshad
    Dec 3, 2004
  3. Athanasius

    setTimeout not working on Mac IE 5.2

    Athanasius, May 3, 2005, in forum: Javascript
    Replies:
    2
    Views:
    415
    Richard Cornford
    May 7, 2005
  4. James Black

    setTimeout not working on IE

    James Black, Apr 14, 2006, in forum: Javascript
    Replies:
    2
    Views:
    642
    Randy Webb
    Apr 14, 2006
  5. SetTimeout not working

    , Aug 14, 2006, in forum: Javascript
    Replies:
    3
    Views:
    140
    Dr John Stockton
    Aug 14, 2006
Loading...

Share This Page