Internet Explorer刷新后不会更新AJAX处理的内容吗? [英] Internet Explorer won't update AJAX handled content on refresh?
问题描述
我有一个页面,该页面通过Jquery AJAX调用从XML文件中获取内容.
I have a page that grabs content from a XML file through a Jquery AJAX call.
问题在于,它将为除IE之外的所有浏览器刷新XML文件中的内容.
The problem is it will update the content from the XML file on a refresh for every browser except IE.
我试图通过元标记来解决这个问题
I have tried to solve this with meta tags
<meta http-equiv="expires" content="-1"/>
<meta http-equiv="cache-control" content="no-cache,must-revalidate" />
<meta http-equiv="pragma" content="no-cache"/>
这是相关javascript的一小部分
This is a small portion of the relevant javascript
$(document).ready(function(){
$.ajax({type: "GET",url: "file1.xml",dataType: "xml", success: parseXml });
}
function parseXml(xml){
document.getElementById(eventMonthName).innerHTML=firstxmlvari.getElementsByTagName('month')[0].childNodes[0].nodeValue;
}
任何建议将不胜感激!
推荐答案
是的,可能您遇到了IE的攻击性缓存...尝试设置HTTP标头,但对我有用的是将当前时间附加到查询字符串中,如下所示:
Yes, probably you run into IE's agressive caching... Try setting the HTTP headers, but something that works for me, is appending the current time to the query string like this:
$(document).ready(function() {
$.ajax({
type: "GET",
url: "/echo/xml/",
data: {
_rnd: new Date().getTime()
},
dataType: "xml",
success: parseXml
});
});
function parseXml(xml) {
alert(xml);
}
关于JSFIDDLE的示例: http://jsfiddle.net/WVBDc/,检查传出的HTTP请求
An example on JSFIDDLE: http://jsfiddle.net/WVBDc/, check the outgoing HTTP requests.
这篇关于Internet Explorer刷新后不会更新AJAX处理的内容吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!