2010-11-24 61 views
2

每當頁面緩存在Firefox和Webkit中時,它都會失去所有ajax功能。緩存頁面AJAX不工作

<html manifest=cache.manifest> 
<head> 
    <script src="js/jquery.js" type="text/javascript"></script> 
    <script src="js/jqtouch.js" type="text/javascript"></script> 

它只會檢索已被緩存的頁面,不管是什麼。有人知道怎麼修這個東西嗎? 在此先感謝! 編輯:Ajax代碼:

var http = false; 
    if(navigator.appName == "Microsoft Internet Explorer") { 
     http = new ActiveXObject("Microsoft.XMLHTTP"); 
    } else { 
     http = new XMLHttpRequest(); 
    } 

    http.open("GET", "default.css", true); 
http.setRequestHeader('CacheControl', "no-cache"); 
    http.onreadystatechange=function() { 
    if(http.readyState == 4) { 
     alert('4(good):'+http.responseText); 
    } 
    } 
    http.send(null); 

而且使用jQuery $就的請求。既沒有工作。 JQuery的:

$.ajax({ 

    url: site_url, 

    cache: false, 

    dataType: 'html', 

    data: ({uuid : devid}), 

    success: function(response){ 

他們總是說成功,但只有當頁面緩存返回數據。否則它們返回null「」。

最後一件事:我請求的頁面不在清單上,因爲一個相當大的服務器端後端。不可能在清單中包含所有頁面。

基本上,我將如何訪問不在同一站點AJAX清單上的頁面。每當我嘗試目前它總是返回null。 return 03:11:41,即使沒有緩存等。

+0

我不這麼認爲,只有服務器到服務器的調用不會第二次,客戶端到服務器的調用應該工作。你是否在做頁面級緩存 – kobe 2010-11-24 02:45:10

+0

你可以給我們更多的細節,比如你的ajax代碼調用後端。 – kobe 2010-11-24 02:48:44

+0

歡迎來到stackoverflow – 2010-11-24 02:52:16

回答

1

這是不正確的。如果您明確從網頁請求數據,則會爲您重新下載。您可以通過打開Firebug或Chrome的調試窗口來查看,並觀看瀏覽器發出的http請求。

+0

我將如何明確要求它? – Precursor 2010-11-24 02:49:15

0

默認情況下,jquery的ajax函數將它接收到的數據(json & jsonp除外)。你可以告訴Ajax調用不使用以下緩存:

$.ajax({ 
    cache: false 
}) 
0

下面的代碼在IE中調用服務器,因爲你是它的緩存不做後續調用...

if(navigator.appName == "Microsoft Internet Explorer") { 
     http = new ActiveXObject("Microsoft.XMLHTTP"); 
1

我我一直試圖讓cache.manifest工作一段時間,並一直給我類似的迴應。我有一個使用Web服務的jQuery Mobile的應用程序,以獲取它的數據,並沒有工作,直到我加入了Web服務進入我cache.manifest文件的網絡部分

CACHE MANIFEST 
    # This is a comment. 
# Cache manifest version 0.1.3.5 
# If you change the version number in this comment, 
# the cache manifest is no longer byte-for-byte 
# identical. 




NETWORK: 
# All URLs that start with the following lines 
# are whitelisted. 

Service.svc 

CACHE: 
# Additional items to cache. 

src/jquery-1.6.2.min.js 
src/jstorage.min.js 
src/jquery.numeric.js 
src/jquery.format-1.1.min.js 
assets/json2.min.js 
assets/jquery.signaturepad.css 
assets/jquery.signaturepad.min.js 
jquery.mobile-1.0b2/jquery.mobile-1.0b2.min.css 
jquery.mobile-1.0b2/jquery.mobile-1.0b2.min.js 
jquery.mobile-1.0b2/images/ajax-loader.png 
jquery.mobile-1.0b2/images/icon-search-black.png 
jquery.mobile-1.0b2/images/icons-18-black.png 
jquery.mobile-1.0b2/images/icons-18-white.png 
jquery.mobile-1.0b2/images/icons-36-black.png 
jquery.mobile-1.0b2/images/icons-36-white.png 
src/link-1-3.js 
src/events-1-3.js 
src/custom-styles.css 
Login.html