Skip to content

Commit b9a8195

Browse files
committed
1 parent 47f7cf0 commit b9a8195

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

jquery.form.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
22
* jQuery Form Plugin
3-
* version: 3.09 (16-APR-2012)
3+
* version: 3.11 (20-JUL-2012)
44
* @requires jQuery v1.3.2 or later
55
*
66
* Examples and documentation at: http://malsup.com/jquery/form/
@@ -210,17 +210,17 @@ $.fn.ajaxSubmit = function(options) {
210210
this.trigger('form-submit-notify', [this, options]);
211211
return this;
212212

213-
// This is a utility function to fix deep serialization issues when doing file uploads
214-
// eg params show up as "[object Object]" rather than what it should be
215-
function formDeepSerialize(extraData){
216-
var serialized = $.param(extraData).split('&');
217-
var result = {};
218-
var n;
219-
for(var i=0, l=serialized.length; i < l; i++){
220-
n = serialized[i].split('=')
221-
result[decodeURIComponent(n[0])] = decodeURIComponent(n[1])
222-
}
223-
return result;
213+
// utility fn for deep serialization
214+
function deepSerialize(extraData){
215+
var serialized = $.param(extraData).split('&');
216+
var len = serialized.length;
217+
var result = {};
218+
var i, part;
219+
for (i=0; i < len; i++) {
220+
part = serialized[i].split('=');
221+
result[decodeURIComponent(part[0])] = decodeURIComponent(part[1]);
222+
}
223+
return result;
224224
}
225225

226226
// XMLHttpRequest Level 2 file uploads (big hat tip to francois2metz)
@@ -232,7 +232,7 @@ $.fn.ajaxSubmit = function(options) {
232232
}
233233

234234
if (options.extraData) {
235-
var serializedData = formDeepSerialize(options.extraData);
235+
var serializedData = deepSerialize(options.extraData);
236236
for (var p in serializedData)
237237
if (serializedData.hasOwnProperty(p))
238238
formdata.append(p, serializedData[p]);
@@ -267,11 +267,11 @@ $.fn.ajaxSubmit = function(options) {
267267
}
268268

269269
s.data = null;
270-
var beforeSend = s.beforeSend;
271-
s.beforeSend = function(xhr, o) {
272-
o.data = formdata;
273-
if(beforeSend)
274-
beforeSend.call(o, xhr, options);
270+
var beforeSend = s.beforeSend;
271+
s.beforeSend = function(xhr, o) {
272+
o.data = formdata;
273+
if(beforeSend)
274+
beforeSend.call(this, xhr, o);
275275
};
276276
$.ajax(s);
277277
}

0 commit comments

Comments
 (0)