Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Urgent problem - IE doesn't refresh with AJAX 1

Status
Not open for further replies.

tcardoso

Programmer
Jan 31, 2005
56
PT
Hi...

I have a page with AJAX call onload... but in IE if I have in definitions to search for an update of the page automatically (most users have)... then the ajax code its not going to the server it simply shows what the result that IE have on temporary files.

I cannot ask to all users to put in definitions "always get the page"... So what can I do? In firefox this problem isn't happening.

Please help
Telmo Cardoso
 
I created my own custom AJAX object, and the way I get around this is appending a timestamp to the querystring on the AJAX call. With a unique timestamp in the querystring the server will treat it as a new request each time - so you never pull cached data. These 2 lines are straight from my ajax.js file and they fix the problem you mentioned:
Code:
var ajaxRightNow = new Date();
var noCacheAjaxurl = ajaxurl + ((/\?/.test(ajaxurl)) ? "&" : "?") + "ajaxRandomTimestamp=" + ajaxRightNow.getTime();

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson
 
I give you a star... that function is so simple that I feel stupid :D lol

Thanks
Telmo Cardoso
 
Thanks for the
star.gif


-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top