Skip to content

Commit d3aacbf

Browse files
committed
Fix #162: New property ajaxSettings to allow configuring ajax params
1 parent e2ef8fc commit d3aacbf

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

CHANGE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ version 4.1.7
1616
- `progressCompleteClass`: styling for progress bar when upload is complete
1717
9. (bug #159): Ensure filestack is passed correctly with `outData` for events.
1818
10. (bug #160): Correct documentation typo for usage.
19+
11. (enh #162): New property ajaxSettings to allow configuring ajax params.
1920

2021
version 4.1.6
2122
=============

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,9 @@ _string_ markup for additional action buttons to display within the initial prev
894894
#### textEncoding
895895
_string_ the encoding to be used while reading a text file. Applicable only for previewing text files. Defaults to `UTF-8`.
896896

897+
#### ajaxSettings
898+
_object_ additional ajax settings to pass to the plugin before submitting the ajax request. Applicable only for ajax uploads. This can be useful to pass additional tokens to headers or one can use it for setting other ajax options for advanced cases. Refer the [jQuery ajax documentation](http://api.jquery.com/jQuery.ajax/) for the various settings you can configure.
899+
897900
### Plugin Events
898901
The plugin supports these events:
899902

js/fileinput.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -957,9 +957,9 @@
957957
return xhrobj;
958958
},
959959
ajaxSubmit: function (fnBefore, fnSuccess, fnComplete, fnError) {
960-
var self = this;
960+
var self = this, settings;
961961
self.uploadExtra();
962-
self.ajaxRequests.push($.ajax({
962+
settings = $.extend(self.ajaxSettings, {
963963
xhr: function () {
964964
var xhrobj = $.ajaxSettings.xhr();
965965
return self.initXhr(xhrobj, 98);
@@ -975,7 +975,8 @@
975975
success: fnSuccess,
976976
complete: fnComplete,
977977
error: fnError
978-
}));
978+
});
979+
self.ajaxRequests.push($.ajax(settings));
979980
},
980981
uploadSingle: function (i, files, allFiles) {
981982
var self = this, total = self.getFileStack().length, formdata = new FormData(), outData,
@@ -1757,7 +1758,8 @@
17571758
dropZoneTitleClass: 'file-drop-zone-title',
17581759
fileActionSettings: {},
17591760
otherActionButtons: '',
1760-
textEncoding: 'UTF-8'
1761+
textEncoding: 'UTF-8',
1762+
ajaxSettings: {}
17611763
};
17621764

17631765
$.fn.fileinput.Constructor = FileInput;

js/fileinput.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)