缓存页面 AJAX 不起作用
每当一个页面同时在 Firefox 和 Webkit 中缓存时,它就会失去所有 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 $.ajax 进行请求。都不起作用。 JQuery:
$.ajax({
url: site_url,
cache: false,
dataType: 'html',
data: ({uuid : devid}),
success: function(response){
他们总是说成功,但只有在页面被缓存时才返回数据。否则它们返回空“”。
最后一件事:由于服务器端后端相当大,我请求的页面不在清单上。不可能将所有页面都包含在清单中。
基本上,我如何访问不在同一站点 AJAX 清单上的页面。每当我当前尝试时,它总是返回 null。 返回 03:11:41,即使没有缓存等。
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?
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
那不是真的。如果您明确从页面请求数据,它会为您重新下载。您可以通过打开 Firebug 或 Chrome 的调试窗口来检查这一点,并观察浏览器发出 http 请求。
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.
我一直在尝试让 cache.manifest 工作一段时间,它一直给我类似的响应。我有一个 jquery 移动应用程序,它使用 Web 服务来获取其数据,并且直到我将 Web 服务添加到我的 cache.manifest 文件的 NETWORK 部分后才开始工作
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
默认情况下,jquery 的 ajax 函数将接收它接收的数据(json 和 jsonp 除外)。您可以使用以下命令告诉 ajax 调用不要缓存:
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:
IE 中的以下代码进行服务器调用,因为您正在缓存它而不进行后续调用...
The below code in IE makes a server call , as you are caching its not making subsequent calls...