Jquery AjaxForm 在 https 协议中的 OPERA 中返回 False
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
jQuery 创建一个隐藏的 IFRAME 来将表单提交到其中,因为这是以 AJAXy 方式处理文件上传的唯一方法。
该问题的根本原因是,当将空 iframe 插入到文档中时,Opera 会触发 onload。 jQuery 脚本预计不会发生此初始 onload 事件,认为提交表单已完成,并得出结论认为未成功。它在 http 上不那么容易发生的原因大概与 Opera 必须加密文件上传有效负载时的时间不同有关。
如果插入 IFRAME 的同一脚本也启动文档加载到 IFRAME 中,则其他浏览器将等待加载文档完成加载,并且仅触发一个加载事件。 (或者类似的东西 - 在这种特定情况下,启动文档加载的脚本是在超时后运行的,所以它甚至不是同一个脚本)。
我建议的修复方法是增强针对此问题已经存在的解决方法尝试:
并检查此 if 语句 IFRAME 内文档的 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:
and check in this if statement whether the URL of the document inside the IFRAME is still the initial javascript:false :
This should be enough to make sure jQuery waits until the new document is done loading.
通过迁移到 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)