0

这很奇怪——我的 ajax 调用返回缓存在 IE 中,而它们在 FF 中的行为正常;任何想法为什么?

function createRequestObject(){
    var req;
    if(window.XMLHttpRequest){
        //For Firefox, Safari, Opera
        req = new XMLHttpRequest();
    }
    else if(window.ActiveXObject){
        //For IE 5+
        req = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else{
        //Error for an old browser
        alert('Your browser is not IE 5 or higher, or Firefox or Safari or Opera');
    }
    //alert (req);
    return req;
}

//Make the XMLHttpRequest Object
var http = createRequestObject();      

var head;

function sendRequestTwo(method, url, head1){
    head = head1
    if(method == "get" || method == "GET"){
        http.open(method,url);
        http.onreadystatechange = handleResponseTwo;
        http.send(null);
            }
}

function handleResponseTwo(){
    if(http.readyState == 4 && http.status == 200){
        var response = http.responseText;
        if(response){  
            document.getElementById(head).innerHTML = response;
            //window.scrollBy(0, 200);
        }
    }      
}
4

2 回答 2

3

我有同样的问题。IE 可以非常积极地缓存。

尝试在您的网址中添加时间戳:

url += '?ts=' + new Date().getTime();
于 2012-04-25T20:21:09.133 回答
1

IE 积极缓存 ajax - 添加具有日期或其他唯一内容的查询字符串以防止它发生。

于 2012-04-25T20:20:18.073 回答