Skip to content

Commit

Permalink
- increase dom wait time for file uploads
Browse files Browse the repository at this point in the history
- remove 'return false' from submit handler
  • Loading branch information
malsup committed Feb 26, 2010
1 parent ab23940 commit 7a59772
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions jquery.form.js
@@ -1,6 +1,6 @@
/*
* jQuery Form Plugin
* version: 2.39 (19-FEB-2010)
* version: 2.40 (26-FEB-2010)
* @requires jQuery v1.3.2 or later
*
* Examples and documentation at: http://malsup.com/jquery/form/
Expand Down Expand Up @@ -209,7 +209,7 @@ $.fn.ajaxSubmit = function(options) {
if (xhr.aborted)
return;

var cbInvoked = 0;
var cbInvoked = false;
var timedOut = 0;

// add submitting element to data if we know it
Expand Down Expand Up @@ -277,12 +277,11 @@ $.fn.ajaxSubmit = function(options) {
else
setTimeout(doSubmit, 10); // this lets dom updates render

var domCheckCount = 50;
var domCheckCount = 100;

function cb() {
if (cbInvoked++) return;

$io.removeData('form-plugin-onload');
if (cbInvoked)
return;

var ok = true;
try {
Expand All @@ -298,14 +297,14 @@ $.fn.ajaxSubmit = function(options) {
if (--domCheckCount) {
// in some browsers (Opera) the iframe DOM is not always traversable when
// the onload callback fires, so we loop a bit to accommodate
cbInvoked = 0;
setTimeout(cb, 100);
setTimeout(cb, 250);
return;
}
log('Could not access iframe DOM after 50 tries.');
log('Could not access iframe DOM after 100 tries.');
return;
}

cbInvoked = true;
xhr.responseText = doc.body ? doc.body.innerHTML : null;
xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
xhr.getResponseHeader = function(header){
Expand Down Expand Up @@ -346,6 +345,7 @@ $.fn.ajaxSubmit = function(options) {

// clean up
setTimeout(function() {
$io.removeData('form-plugin-onload');
$io.remove();
xhr.responseXML = null;
}, 100);
Expand Down Expand Up @@ -380,9 +380,9 @@ $.fn.ajaxSubmit = function(options) {
* the form itself.
*/
$.fn.ajaxForm = function(options) {
return this.ajaxFormUnbind().bind('submit.form-plugin', function() {
return this.ajaxFormUnbind().bind('submit.form-plugin', function(e) {
e.preventDefault();
$(this).ajaxSubmit(options);
return false;
}).bind('click.form-plugin', function(e) {
var target = e.target;
var $el = $(target);
Expand Down

0 comments on commit 7a59772

Please sign in to comment.