2013-05-13 48 views
0
if(xmlhttp) { 
xmlhttp.open("GET","DokterWeek_KlantoverzichtServletAjax?" + $(this).prop("href").split("?")[1],true);//gettime will be the servlet name 
xmlhttp.onreadystatechange = handleServerResponse; 
xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 
xmlhttp.send(null); 
} 

}); 
}); 



function getXMLObject() //XML OBJECT 
{ 
var xmlHttp = false; 
try { 
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP") // For Old Microsoft Browsers 
    } 
    catch (e) { 
    try { 
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP") // For Microsoft IE 6.0+ 
    } 
    catch (e2) { 
    xmlHttp = false // No Browser accepts the XMLHTTP Object then false 
    } 
    } 
    if (!xmlHttp && typeof XMLHttpRequest != 'undefined') { 
    xmlHttp = new XMLHttpRequest();  //For Mozilla, Opera,chrome Browsers 
    } 
    return xmlHttp; // Mandatory Statement returning the ajax object created 
    } 





    var xmlhttp = new getXMLObject(); //xmlhttp holds the ajax object 


    function handleServerResponse() { 

    document.getElementById("pop1").innerHTML = xmlhttp.responseText; //Update the HTML    Form element 

    } 

你好,我 有以下問題(代碼工作)了XMLHttpRequest(AJAX調用),當我使用refreches Firefox或Chrome(所以它的工作原理很漂亮)。但IE 9.0+緩存XMLHttprequest,所以它永遠不會刷新。我在網上讀了很多這個問題,但是我真的找不到解決這個問題的辦法。如何讓XMLHttpRequest的不CACH在IE

有人可以告訴我解決這個問題的可能性嗎? 我認爲使用jquery ajax是可以修復的,但我沒有大腦將整個腳本調整爲jquery。有人說你可以將實時時間設置爲0,但我沒有找到它。 (我用servlet傳遞我的Ajax) 有人知道一個清晰,更簡單的解決方案嗎?

非常感謝您

回答

1

一旦接受的做法是一個隨機參數添加到像時間戳的URL。又一個偉大的答案

xmlhttp.open("GET","DokterWeek_KlantoverzichtServletAjax?_d=" + (new Date().getTime()) + '&' + $(this).prop("href").split("?")[1], true);//gettime will be the servlet name 
+0

阿倫P約翰尼拉,謝謝:

_d到URL添加參數和值new Date().getTime()

防爆!真的很完美 – RobinHo 2013-05-13 09:21:53