开发者

jquery ui tabs not refreshing in IE

Hello I have a page with some jquery ui tabs on it and they work fine in chrome and firefox but in IE开发者_运维问答(tested 9) the content always stays the same when a user does an action and the page reloads the content is the same. Could this be because I am using cookies to remember which tab the user was on

<script>
                    $(function() {
                        $( "#tabs" ).tabs({
                            cookie: {
                                expires: 1
                            },
                            ajaxOptions: {
                                error: function( xhr, status, index, anchor ) {
                                    $( anchor.hash ).html(
                                        "Couldn't load this tab. We'll try to fix this as soon as possible.");
                                }
                            }
                        });
                    });
                    </script>


Have you tried setting the ajaxoptions?

$(document).ready(function(){
  $("#tabs").tabs({
    spinner: 'Loading...',
    cache: false,
    ajaxOptions: {cache: false}
  });
});


I have been struggling with a similar problem, JQuery tabs work fine with all browsers except MSIE. The problem turned out to be that MSIE cached all page requests, even when pressing the reload button, and I solved it server-side with the EXPIRES header parameter.

I use Perl and the CGI module, and I added the expires parameter for all page and AJAX requests:

print $q->header({-type=>'text/html', -expires=>'now'}), $HTML_CONTENT;

Hope this can help someone!


I agree that Dusty's answer should be correct. However in my case, it didn't work in IE6. Instead, I used the global jquery ajaxSetup (which is used by the jquery ajax functions, which is used by jqueryui tabs) to turn off caching like so:

$.ajaxSetup({
    cache: false
});

This makes perfect sense to me as I cannot see a reason why I would ever want the browser to cache something I specifically attempted to ajax, but realise this is specific to requirements.

I've done this in my master page so that all pages follow the rule. Curiously, caching is set to true by default yet Firefox ignores it. Seems like its the one time IE did what it was supposed to (even if it was annoying).

References:

http://docs.jquery.com/Ajax/jQuery.ajaxSetup

http://docs.jquery.com/Ajax/jQuery.ajax

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜