开发者

Cached Pages AJAX Not Working

Whenever a page is cached in both Firefox and Webkit, it appears to lose all ajax capabilities.

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

It will only retrieve pages that have been cached, no matter what. Anyone know how to fix this? 开发者_StackOverflow社区Thanks in advance! EDIT: Ajax Code:

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

Also using jquery $.ajax for the request. Neither work. JQuery:

    $.ajax({

    url: site_url,

    cache: false,

    dataType: 'html',

    data: ({uuid : devid}),

    success: function(response){

They always say successful, but only return data if the page is cached. Otherwise they return null "".

One last thing: I am requesting pages not on the manifest, because of a rather large server side backend. It would not be possible to have all pages in the manifest.

Basically, how would I access pages NOT on the manifest on same-site AJAX. Whenever I try currently it always return null. return 03:11:41, even with no-cache, etc.


That's not true. If you explicitly request data from a page it re-downloads it for you. You can check this by opening Firebug, or Chrome's debug window and watch the browser make an http request.


I've been trying to get cache.manifest working for a while now and it kept giving me similar responses. I have a jquery mobile app that uses a web service to get it's data and wasn't working until I added the web service into the NETWORK section of my cache.manifest file

    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


by default jquery's ajax functions will the data it receives (except for json & jsonp). You can tell the ajax call not to cache using the following:

$.ajax({
  cache: false
})


The below code in IE makes a server call , as you are caching its not making subsequent calls...

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜