IE浏览器缓存和jQuery的表格插件 [英] IE browser caching and the jQuery Form Plugin

查看:124
本文介绍了IE浏览器缓存和jQuery的表格插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

像我之前那么多的失魂,我挣扎的蛇坑是Ajax的表单提交和IE浏览器的缓存。

Like so many lost souls before me, I'm floundering in the snake pit that is Ajax form submission and IE browser caching.

我想写使用jQuery表格插件,以Ajaxify字preSS评论一个简单的脚本。它的做工精细的火狐,Chrome,Safari浏览器等。人,但在IE,响应文本被缓存,其结果是Ajax的是拉动在错误的评价。

I'm trying to write a simple script using the jQuery Form Plugin to Ajaxify Wordpress comments. It's working fine in Firefox, Chrome, Safari, et. al., but in IE, the response text is cached with the result that Ajax is pulling in the wrong comment.

    jQuery(this).ajaxSubmit({
        success: 
            function(data) {
                var response = $("<ol>"+data+"</ol>");
                response.find('.commentlist li:last').hide().appendTo(jQuery('.commentlist')).slideDown('slow');
            }           
        });

ajaxSubmit会发送注释WP-评论-post.php中,整个网页,其中吐出粗暴回作为回应。因此,尽管它的丑陋的蟾蜍,我坚持的响应文本中的变量,使用:最后一个隔离的最新评论,并在其位置上滑动下来

ajaxSubmit sends the comment to wp-comments-post.php, which inelegantly spits back the entire page as a response. So, despite the fact that it's ugly as toads, I'm sticking the response text in a variable, using :last to isolate the most recent comment, and sliding it down in its place.

IE浏览器,但是,正在返回的页面,其中不包括新注释的高速缓存版本。因此,.commentlist李:最后的选择的 previous 的意见,其中重复再白白滑下原下方

IE, however, is returning the cached version of the page, which doesn't include the new comment. So ".commentlist li:last" selects the previous comment, a duplicate of which then uselessly slides down beneath the original.

我已经尝试设置缓存:假的ajaxSubmit的选项,但没有效果。我已经尝试设置URL选项和套结对随机数或时间戳,但它卷起被附加到提交评论到服务器,而不是返回响应,所以没有效果的得到这个职位。我不知道还有什么尝试。一切正常的IE浏览器,如果我关掉浏览器缓存,但是这显然不是我能希望任何人查看的页面做的。

I've tried setting "cache: false" in the ajaxSubmit options, but it has no effect. I've tried setting a url option and tacking on a random number or timestamp, but it winds up being attached to the POST that submits the comment to the server rather than the GET that returns the response, and so has no effect. I'm not sure what else to try. Everything works fine in IE if I turn off browser caching, but that's obviously not something I can expect anyone viewing the page to do.

任何帮助将是巨大的AP preciated。提前致谢!

Any help will be hugely appreciated. Thanks in advance!

编辑与进度报告:一对夫妇的人建议使用PHP头以prevent缓存,这确实工作。麻烦的是,WP-评论岗位被吐回整个页面,当一个新的评论被提交,我可以看到的唯一方法添加页眉是把他们的话preSS后的模板,它禁用缓存所有帖子在任何时候 - 不太我正在寻找的行为。

EDIT WITH A PROGRESS REPORT: A couple of people have suggested using PHP headers to prevent caching, and this does indeed work. The trouble is that wp-comments-post is spitting back the entire page when a new comment is submitted, and the only way I can see to add headers is to put them in the Wordpress post template, which disables caching on all posts at all times--not quite the behavior I'm looking for.

有没有一种方法来设置一个PHP有条件的 - 如果is_ajax或者类似的东西 - 这将保持头部的过程中经常pageloads被应用,但将它们插入如果网页被称为一个Ajax得到什么呢?

Is there a way to set a php conditional--"if is_ajax" or something like that--that would keep the headers from being applied during regular pageloads, but plug them in if the page was called by an Ajax GET?

推荐答案

jQuery.ajaxSubmit()采取任何的选择标准 jQuery.ajax()。因此,您可以使用标准的缓存:假选项关闭缓存:

jQuery.ajaxSubmit() takes any of the options for the standard jQuery.ajax(). You can thus use the standard cache: false option to turn off caching:

jQuery(this).ajaxSubmit({
    cache: false,
    success: 
        function(data) {
            var response = $("<ol>"+data+"</ol>");
            response.find('.commentlist li:last').hide().appendTo(jQuery('.commentlist')).slideDown('slow');
        }           
    });

这篇关于IE浏览器缓存和jQuery的表格插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆