Form plugin: dealing with Safari upload 'stalling'
Hello,
Safari has a bug which occasionally makes it 'stall' / 'halt' during
the post of a form that contains a file upload. I don't know under
which specific conditions this problem occurs, but the problem has
been reported by others as well. There is also a hack available to
solve this issue:
- http://www.webmasterworld.com/macintosh_webmaster/3300569.htm
- http://blog.airbladesoftware.com/2007/8/17/note-to-self-prevent-uploads-hanging-in-safari
I did a minor tweak to .ajaxSubmit and I suggest integrating it (or
something similar) into an upcoming release of the Form plugin.
What I did is modifying the following code block (in .ajaxSubmit):
if (options.iframe || found) // options.iframe allows user to
force iframe mode
fileUpload();
else
$.ajax(options);
into:
if (options.iframe || found) // options.iframe allows user to
force iframe mode
// Tim: hack to prevent Safari from 'hanging' during an
upload.
if ($.browser.safari) {
$.get(options.closeKeepAlive, fileUpload);
}
else {
fileUpload();
}
// End Tim
else
$.ajax(options);
in which options.closeKeepAlive is the URL of a webpage, which should
be provided through .ajaxSubmit's options parameter. This webpage
should be just an empty page in which the 'Connection' HTTP header is
set to 'close'.
This hack solves the problem for me. Your opinions are appreciated.
Regards,
Tim Molendijk