Loans - Cheap HP 530 Laptops - Hen Night - Homeowner Loan - Secured Loans

PDA

View Full Version : Help: AJAX, IE7 and Cache


sanjayc
Nov 15th 2006, 1:13 pm
Hello everybody,
I have written a webpage with some AJAX updates.

What happens
1. DB updated
2. Every 10 seconds browser checks server for new information
3. In firefox new info is sent to the browser and end of story.

HOWEVER
3. In IE7 the page does not refresh, I know this is because the GET url (post.php) is stored locally in IE's cache. If I delete all internet cache the page updates. But this is not really a suitable for my users/friends.

What I'm asking is if there is anyway I can make post.php not be cached by IE?

I have tried putting the following code in my post.php
<head>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
</head>

... but that didn't work. I'm kinda of struggling. Any help would be hugely appreciated.

Thanks

sanjayc
Nov 15th 2006, 1:44 pm
Just to let you know I have found the solution and it was pretty simple too.
Change all

xmlHttp.open("GET",url,true)
to
xmlHttp.open("POST",url,true)

Seems to have fixed it for me. Hope it helps you all if you happen to have the same problem.

Cheers
Sanjay

nico_swd
Nov 15th 2006, 2:06 pm
You can also add a random number to the GET url, like that.


var url = 'http://url.com/file.php?r='+ Math.floor(Math.random()*1000);