jquery-form / form

jQuery Form Plugin
https://jquery-form.github.io/form/
GNU Lesser General Public License v2.1
5.2k stars 2.14k forks source link

Fix file upload issues with Opera #3

Closed mpokrywka closed 14 years ago

mpokrywka commented 15 years ago

Despite changes that should fix Opera issues, 2.36 doesn't work correctly for me in Opera. I tested 9.27, 9.52, 9.64 and 10.00 under Ubuntu, upload is always interrupted early. When searching for Opera iframe onload issues, I found note in http://developer.yahoo.com/yui/releasenotes/README.connection and that 2.5.2 issue description gave me idea how to fix this bug: attach onload handler after iframe is inserted into DOM!

After applying following patch, form plugin works flawlessly under Opera (9.27, 9.52, 9.64, 10.00), I also tested (without problems) IE6,7,8 and Fx2,Fx3.

diff --git a/public/javascripts/jquery.form.js b/public/javascripts/jquery.form.js
--- a/public/javascripts/jquery.form.js
+++ b/public/javascripts/jquery.form.js
@@ -261,7 +261,9 @@ $.fn.ajaxSubmit = function(options) {

                                // add iframe to doc and submit the form
                                $io.appendTo('body');
+                               setTimeout(function() {
                                io.attachEvent ? io.attachEvent('onload', cb) : io.addEventListener('load', cb, false);
+                               }, 1);
                                form.submit();
                        }
                        finally {
mworrell commented 14 years ago

I second this, though I got the impression that the first onload event was triggered by the 100 continue, and that the second was triggered by the actual data received. Maybe I am wrong, at least my fix was very similar :-)

mpokrywka commented 14 years ago

I uploaded my changes to github, see: http://github.com/mpokrywka/form You are welcome to test them, FYI: on my site I use options: { iframe: true, iframeSrc: 'javascript:false' }

malsup commented 14 years ago

I believe this is fixed in version 2.40