[thelist] ie caching ajax

Brian Cummiskey Brian at hondaswap.com
Wed May 7 15:48:02 CDT 2008


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();           
        }
    }
 }   



More information about the thelist mailing list