[thelist] ie caching ajax
Christian Heilmann
codepo8 at gmail.com
Wed May 7 18:20:40 CDT 2008
Brian Cummiskey wrote:
> Hi all,
>
> I have an ajax app that I spent a lot of time fine tuning for an ajax post.
>
> I have added a timestamp to the post params so that its unique as many
> examples suggest.
>
> Works flawless in firefox, safari.
>
> In ie7, it works flawless the first time.
>
> the 2nd time you click the submit button, the actual back-end process
> computes, but the display never gets the updated innerHTML.
>
> It's a simple
> post -> process -> re-print the effected area using innerHTML of the
> parent div.
>
>
>
> since the timestamp is on there, and it does post the 2nd time, i don't
> think the problem is actually in my ajax post. The rcartitems div
> stays on the "Adding new items" temp screen, but the back-end process
> does go through
>
>
> <script ......
> /// building stuff here....
>
>
> // stuff that matters below:
>
> document.getElementById("rcartitems").innerHTML = "<ul><li
> class=\"prodtitle margeb\">Adding new items...</li></ul>";
> var url = "/addtocart.asp";
>
> xmlHttp.onreadystatechange = alertContents;
> xmlHttp.open('POST',url,true);
> xmlHttp.setRequestHeader("Content-type",
> "application/x-www-form-urlencoded");
> xmlHttp.setRequestHeader("Content-length", params.length);
> xmlHttp.setRequestHeader("Connection", "close");
> xmlHttp.send(params);
> }
>
> function alertContents() {
>
> if (xmlHttp.readyState == 4) {
> if (xmlHttp.status == 200) {
> result = xmlHttp.responseText;
> document.getElementById("rcartitems").innerHTML = result;
> }
> else {
> //send it the old way if it can't ajax....
> document.getElementById("addtocart").method="post";
> document.getElementById("addtocart").submit();
> }
> }
> }
>
Simply uniquing (that is no word, but it is late) is not enough. Have
you tried setting an expiry date in the past?
xmlHttp.setRequestHeader('If-Modified-Since','Wed, 05 Apr 2006 00:00:00 GMT');
More information about the thelist
mailing list