Mise à jour librairie en version 2.43
This commit is contained in:
parent
06843f7e14
commit
b713da6c55
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*!
|
||||||
* jQuery Form Plugin
|
* jQuery Form Plugin
|
||||||
* version: 2.39 (19-FEB-2010)
|
* version: 2.43 (12-MAR-2010)
|
||||||
* @requires jQuery v1.3.2 or later
|
* @requires jQuery v1.3.2 or later
|
||||||
*
|
*
|
||||||
* Examples and documentation at: http://malsup.com/jquery/form/
|
* Examples and documentation at: http://malsup.com/jquery/form/
|
||||||
@ -124,7 +124,8 @@ $.fn.ajaxSubmit = function(options) {
|
|||||||
if (!options.dataType && options.target) {
|
if (!options.dataType && options.target) {
|
||||||
var oldSuccess = options.success || function(){};
|
var oldSuccess = options.success || function(){};
|
||||||
callbacks.push(function(data) {
|
callbacks.push(function(data) {
|
||||||
$(options.target).html(data).each(oldSuccess, arguments);
|
var fn = options.replaceTarget ? 'replaceWith' : 'html';
|
||||||
|
$(options.target)[fn](data).each(oldSuccess, arguments);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (options.success)
|
else if (options.success)
|
||||||
@ -209,7 +210,7 @@ $.fn.ajaxSubmit = function(options) {
|
|||||||
if (xhr.aborted)
|
if (xhr.aborted)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var cbInvoked = 0;
|
var cbInvoked = false;
|
||||||
var timedOut = 0;
|
var timedOut = 0;
|
||||||
|
|
||||||
// add submitting element to data if we know it
|
// add submitting element to data if we know it
|
||||||
@ -220,8 +221,8 @@ $.fn.ajaxSubmit = function(options) {
|
|||||||
opts.extraData = opts.extraData || {};
|
opts.extraData = opts.extraData || {};
|
||||||
opts.extraData[n] = sub.value;
|
opts.extraData[n] = sub.value;
|
||||||
if (sub.type == "image") {
|
if (sub.type == "image") {
|
||||||
opts.extraData[name+'.x'] = form.clk_x;
|
opts.extraData[n+'.x'] = form.clk_x;
|
||||||
opts.extraData[name+'.y'] = form.clk_y;
|
opts.extraData[n+'.y'] = form.clk_y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -277,12 +278,11 @@ $.fn.ajaxSubmit = function(options) {
|
|||||||
else
|
else
|
||||||
setTimeout(doSubmit, 10); // this lets dom updates render
|
setTimeout(doSubmit, 10); // this lets dom updates render
|
||||||
|
|
||||||
var domCheckCount = 50;
|
var domCheckCount = 100;
|
||||||
|
|
||||||
function cb() {
|
function cb() {
|
||||||
if (cbInvoked++) return;
|
if (cbInvoked)
|
||||||
|
return;
|
||||||
$io.removeData('form-plugin-onload');
|
|
||||||
|
|
||||||
var ok = true;
|
var ok = true;
|
||||||
try {
|
try {
|
||||||
@ -298,14 +298,16 @@ $.fn.ajaxSubmit = function(options) {
|
|||||||
if (--domCheckCount) {
|
if (--domCheckCount) {
|
||||||
// in some browsers (Opera) the iframe DOM is not always traversable when
|
// in some browsers (Opera) the iframe DOM is not always traversable when
|
||||||
// the onload callback fires, so we loop a bit to accommodate
|
// the onload callback fires, so we loop a bit to accommodate
|
||||||
cbInvoked = 0;
|
log('requeing onLoad callback, DOM not available');
|
||||||
setTimeout(cb, 100);
|
setTimeout(cb, 250);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
log('Could not access iframe DOM after 50 tries.');
|
log('Could not access iframe DOM after 100 tries.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log('response detected');
|
||||||
|
cbInvoked = true;
|
||||||
xhr.responseText = doc.body ? doc.body.innerHTML : null;
|
xhr.responseText = doc.body ? doc.body.innerHTML : null;
|
||||||
xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
|
xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
|
||||||
xhr.getResponseHeader = function(header){
|
xhr.getResponseHeader = function(header){
|
||||||
@ -331,7 +333,9 @@ $.fn.ajaxSubmit = function(options) {
|
|||||||
data = $.httpData(xhr, opts.dataType);
|
data = $.httpData(xhr, opts.dataType);
|
||||||
}
|
}
|
||||||
catch(e){
|
catch(e){
|
||||||
|
log('error caught:',e);
|
||||||
ok = false;
|
ok = false;
|
||||||
|
xhr.error = e;
|
||||||
$.handleError(opts, xhr, 'error', e);
|
$.handleError(opts, xhr, 'error', e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,6 +350,7 @@ $.fn.ajaxSubmit = function(options) {
|
|||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
|
$io.removeData('form-plugin-onload');
|
||||||
$io.remove();
|
$io.remove();
|
||||||
xhr.responseXML = null;
|
xhr.responseXML = null;
|
||||||
}, 100);
|
}, 100);
|
||||||
@ -380,9 +385,9 @@ $.fn.ajaxSubmit = function(options) {
|
|||||||
* the form itself.
|
* the form itself.
|
||||||
*/
|
*/
|
||||||
$.fn.ajaxForm = function(options) {
|
$.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);
|
$(this).ajaxSubmit(options);
|
||||||
return false;
|
|
||||||
}).bind('click.form-plugin', function(e) {
|
}).bind('click.form-plugin', function(e) {
|
||||||
var target = e.target;
|
var target = e.target;
|
||||||
var $el = $(target);
|
var $el = $(target);
|
||||||
@ -658,8 +663,13 @@ $.fn.selected = function(select) {
|
|||||||
// helper fn for console logging
|
// helper fn for console logging
|
||||||
// set $.fn.ajaxSubmit.debug to true to enable debug logging
|
// set $.fn.ajaxSubmit.debug to true to enable debug logging
|
||||||
function log() {
|
function log() {
|
||||||
if ($.fn.ajaxSubmit.debug && window.console && window.console.log)
|
if ($.fn.ajaxSubmit.debug) {
|
||||||
window.console.log('[jquery.form] ' + Array.prototype.join.call(arguments,''));
|
var msg = '[jquery.form] ' + Array.prototype.join.call(arguments,'');
|
||||||
|
if (window.console && window.console.log)
|
||||||
|
window.console.log(msg);
|
||||||
|
else if (window.opera && window.opera.postError)
|
||||||
|
window.opera.postError(msg);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user