I've been going through (a bit dated) AJAX textbook examples. Nice and simple examples worked out fine, so I attempted to modify one of them like this:
On my html page have a button which on click calls a javascript function that requests a random number from my PHP file which is than displayed in a div on my html page.
Not much modification needed and everything works fine in Firefox, Chrome and Opera. In IE8 (yes, I'm still on Windows XP) the setup works, but only the first time every other click leaves the first generated number as the div value.
After some searching I found this:
An IE AJAX gotcha: page caching
"It appears that IE is prone to malfunctioning, unless a document accessed through AJAX has its HTTP header set to disallow caching."
And the solution is to put the following response headers in the page:
Just when I was getting the hang of it...
On my html page have a button which on click calls a javascript function that requests a random number from my PHP file which is than displayed in a div on my html page.
Not much modification needed and everything works fine in Firefox, Chrome and Opera. In IE8 (yes, I'm still on Windows XP) the setup works, but only the first time every other click leaves the first generated number as the div value.
After some searching I found this:
An IE AJAX gotcha: page caching
"It appears that IE is prone to malfunctioning, unless a document accessed through AJAX has its HTTP header set to disallow caching."
And the solution is to put the following response headers in the page:
<?php header("Expires: Sun, 19 Nov 1978 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
?>Just when I was getting the hang of it...
Help












