SetTimeout not working with IE

S

Shan

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
 
D

David Mark

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.
 
S

Shan

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.
 
D

David Mark


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]
 
T

Thomas 'PointedEars' Lahn

David said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top