Skip to content

Commit

Permalink
Merge pull request #262 from 2degrees/master
Browse files Browse the repository at this point in the history
Added support for functions in 'data' option for ajaxForm and ajaxSubmit.
  • Loading branch information
kevindb authored Feb 20, 2017
2 parents bf5dc17 + 29d282b commit 04b3a20
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions jquery.form.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,9 @@ $.fn.ajaxSubmit = function(options) {
var elements = [];
var qx, a = this.formToArray(options.semantic, elements, options.filtering);
if (options.data) {
options.extraData = options.data;
qx = $.param(options.data, traditional);
var optionsData = $.isFunction(options.data) ? options.data(a) : options.data;
options.extraData = optionsData;
qx = $.param(optionsData, traditional);
}

// give pre-submit callback an opportunity to abort the submit
Expand Down Expand Up @@ -275,16 +276,14 @@ $.fn.ajaxSubmit = function(options) {
var result = [];
var i, part;
for (i=0; i < len; i++) {
// #252; undo param space replacement
serialized[i] = serialized[i].replace(/\+/g,' ');
part = serialized[i].split('=');
// #278; use array instead of object storage, favoring array serializations
result.push([decodeURIComponent(part[0]), decodeURIComponent(part[1])]);
}
return result;
}

// XMLHttpRequest Level 2 file uploads (big hat tip to francois2metz)
// XMLHttpRequest Level 2 file uploads (big hat tip to francois2metz)
function fileUploadXhr(a) {
var formdata = new FormData();

Expand Down

0 comments on commit 04b3a20

Please sign in to comment.