如何阻止IE7-8缓存此jQuery函数的显示?

mar*_*dge 14 jquery internet-explorer

每次在jQuery Tabs UI中有标签更改时,我都会使用下面的函数在#quotescontainer中显示随机引用.除了IE7-8(当然)以外的一切都可以正常工作.

IE7-8中发生的情况是显示第一个引号,第二个随机引用出现在第一个引号正下方的#quotescontainer中.在所有其他浏览器中,只显示一个引号,并在选项卡更改时轮换.因此,IE从quotes.html获取div.quote中的第一个引用,显示它并在第一个引号下面显示随机引用.

我可以尝试强制IE正确交换引号?而不是第一次引用"卡住"?

这是缓存问题吗?或者函数的问题总是读取quote1并在其下面附加quote2?

我没有在.htaccess中使用缓存.我试过添加$.ajaxSetup({cache: false});功能没有运气.

6/01/11修复; 问题是<div class="quote">quote text</div>在quotes.html中的一些html .不知何故,这打破了IE7-8.

jsfiddle: http ://jsfiddle.net/YAEe5/28/

我的职责: 在Matthew Ratzloff的帮助下

    select: function(event, ui) {

    var random = Math.floor(Math.random() * (Math.pow(2, 32) - 1));
  $('div#quotescontainer').load('http://mydomain.com/quotes.html?' + random, function() {
    var quotes = $(this).find('div.quote');
    var index = Math.floor(Math.random() * quotes.length);
    quotes.hide().eq(index).fadeIn();
  });
Run Code Online (Sandbox Code Playgroud)

引号显示在页面上#quotescontainer

quotes.html包含:

<div class="quote">Quote1</div>
<div class="quote">Quote2</div>
<div class="quote">Quote3</div>
Run Code Online (Sandbox Code Playgroud)

Mat*_*off 8

这是一个完整的,经过测试的工作示例,说明您想要做什么.您应该能够将$(document).ready函数内部的所有内容都放入select处理程序中.

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script>
</head>
<script>
$(document).ready(function() {
  var random = Math.floor(Math.random() * (Math.pow(2, 32) - 1));
  $('div#quotescontainer').load('quotes.html?' + random, function() {
    var quotes = $(this).find('div.quote');
    var index = Math.floor(Math.random() * quotes.length);
    quotes.hide().eq(index).fadeIn();
  });
});
</script>
<div id="quotescontainer"></div>
</html>
Run Code Online (Sandbox Code Playgroud)