Jquery AjaxForm 在 https 协议中的 OPERA 中返回 False

发布于 2024-09-06 06:59:00 字数 184 浏览 2 评论 0原文

仅当我添加文件输入时才会显示该错误。我在成功事件中得到 FALSE 的返回。只发生在歌剧中。

知道哪里可能有问题吗?

http://jquery.malsup.com/form/

The error is shown only when i add a File input. I get a return of FALSE in the success event. happens only in Opera.

Any idea where could be a problem ?

http://jquery.malsup.com/form/

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

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

发布评论

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

评论(2

一百个冬季 2024-09-13 06:59:00

jQuery 创建一个隐藏的 IFRAME 来将表单提交到其中,因为这是以 AJAXy 方式处理文件上传的唯一方法。

该问题的根本原因是,当将空 iframe 插入到文档中时,Opera 会触发 onload。 jQuery 脚本预计不会发生此初始 onload 事件,认为提交表单已完成,并得出结论认为未成功。它在 http 上不那么容易发生的原因大概与 Opera 必须加密文件上传有效负载时的时间不同有关。

如果插入 IFRAME 的同一脚本也启动文档加载到 IFRAME 中,则其他浏览器将等待加载文档完成加载,并且仅触发一个加载事件。 (或者类似的东西 - 在这种特定情况下,启动文档加载的脚本是在超时后运行的,所以它甚至不是同一个脚本)。

我建议的修复方法是增强针对此问题已经存在的解决方法尝试:

if (!isXml && (doc.body == null || doc.body.innerHTML == ''  )) 

并检查此 if 语句 IFRAME 内文档的 URL 是否仍然是初始 javascript:false :

if (!isXml && (doc.body == null || doc.body.innerHTML == '' || doc.URL=='javascript:false' )) 

这应该足以确保 jQuery 等待新文档已完成加载。

jQuery creates a hidden IFRAME to submit the form into, because this is the only way to handle a file upload in an AJAXy way.

The underlying reason for the problem is that Opera fires onload when an empty iframe is inserted into the document. The jQuery script doesn't expect this initial onload event, thinks submitting the form is done, and concludes that it was not successful. The reason it doesn't happen as easily on http presumably has to do with the timing being different when Opera has to encrypt a file upload payload.

If the same script that inserts the IFRAME also initiates document loading into the IFRAME, other browsers will wait until the loading document finishes loading and only fire one load event. (Or something like that - in this specific case, the script that starts document loading is running from a timeout, so it's not even the same script).

My suggested fix would be to enhance the workaround attempt that already exists for this problem:

if (!isXml && (doc.body == null || doc.body.innerHTML == ''  )) 

and check in this if statement whether the URL of the document inside the IFRAME is still the initial javascript:false :

if (!isXml && (doc.body == null || doc.body.innerHTML == '' || doc.URL=='javascript:false' )) 

This should be enough to make sure jQuery waits until the new document is done loading.

慕烟庭风 2024-09-13 06:59:00

通过迁移到 jQuery 1.5 和最后一个 jQuery Form 插件(2.63),这个问题看起来已经解决了

The issue looks resolved for me with moving to jQuery 1.5 and the last jQuery Form plugin (2.63)

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