Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > SetTimeout not working with IE

Reply
Thread Tools

SetTimeout not working with IE

 
 
Shan
Guest
Posts: n/a
 
      02-22-2008
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

 
Reply With Quote
 
 
 
 
David Mark
Guest
Posts: n/a
 
      02-22-2008
On Feb 22, 3:10*am, Shan <(E-Mail Removed)> 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.

 
Reply With Quote
 
 
 
 
Shan
Guest
Posts: n/a
 
      02-22-2008
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 <(E-Mail Removed)> wrote:
> On Feb 22, 3:10 am, Shan <(E-Mail Removed)> 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.


 
Reply With Quote
 
David Mark
Guest
Posts: n/a
 
      02-22-2008
On Feb 22, 8:34*am, Shan <(E-Mail Removed)> 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]
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      02-24-2008
David Mark wrote:
> On Feb 22, 3:10 am, Shan <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SetTimeout not working Darren.Ratcliffe@gmail.com Javascript 3 08-14-2006 10:32 PM
javascript setTimeout does not work =?Utf-8?B?RQ==?= ASP .Net 4 05-02-2006 08:21 PM
setTimeout not working on IE James Black Javascript 2 04-14-2006 06:37 PM
setTimeout not working on Mac IE 5.2 Athanasius Javascript 2 05-07-2005 12:29 AM
SetTimeout not working correctly in IE tshad Javascript 4 12-03-2004 04:45 PM



Advertisments