IE8提交表单但有时不刷新页面

发布于 2024-10-07 23:42:10 字数 336 浏览 0 评论 0原文

我有一个按钮,当我单击该按钮时,一个函数起作用,它调用 jQuery .submit 函数。

我使用 jQuery 1.4.2。

但是,有时它提交但不刷新页面。我刚刚在 IE8 上遇到这个问题。

实际上它可以在 IE8 上运行,但有时会遇到这个问题,有时则不会。

我的页面是这样的;有一些文本字段和每个文本字段附近的复选框。我选中复选框并按下删除按钮,它提交值并且该文本字段消失(它在服务器端删除,页面重新加载在服务器端保存的所有文本字段)。问题是,有时该文本字段不会从屏幕上消失,但如果我重新输入页面的 url 并按 Enter 或 F5 页面或选中复选框并再次按删除按钮,一切都会正常...

I have a button and when I click that button a function works, it calls jQuery .submit function.

I use jQuery 1.4.2.

However, sometimes it submits but doesn't refresh the page. I got this problem just on IE8.

Actually it works on IE8 but sometimes I get this problem and sometimes not.

My page is like that; there are some text fields and a chechboxes near every text field. I check the checkbox and push the delete button, it submits the value and that text field disappear(it is deleted at server side and the page reloads all the text fields that saved at server side). The problem is that sometimes that textfield doesn't disappear from the screen but if I re-enter page's url and push enter or F5 the page or check the checkbox and push the delete button again everything works fine...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

萌梦深 2024-10-14 23:42:10

听起来像是浏览器缓存问题。为了解决这个问题,当您提交表单时,请在其 action 中添加随机值,从而欺骗浏览器认为它是不同的页面,因此不会从缓存中加载内容。

示例代码:

var rand = parseInt(Math.random() * 1000000 + 100000);
$(form).attr("action", "mypage.php?r=" + rand);
...

Sounds like browser caching issue. To solve this, when you submit the form add random value to its action, thus tricking the browser to think it's different page so it won't load the contents from its cache.

Sample code:

var rand = parseInt(Math.random() * 1000000 + 100000);
$(form).attr("action", "mypage.php?r=" + rand);
...
迷鸟归林 2024-10-14 23:42:10

问题出在我的服务器端结构上,与 ie8 无关。

Problem was about my server side structure, was not related to only ie8.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文