Add contentType option for AjaxRequest
authorMatthias Schmidt <gravatronics@live.com>
Wed, 23 Sep 2015 15:52:52 +0000 (17:52 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Wed, 23 Sep 2015 15:52:52 +0000 (17:52 +0200)
wcfsetup/install/files/js/WoltLab/WCF/Ajax/Request.js

index 675c8cfd328a71a891724ba1d13dd344ecdcdb60..f329ac1db2dd35adfce9f55003edb40ea909b6f8 100644 (file)
@@ -35,6 +35,7 @@ define(['Core', 'Language', 'Dom/ChangeListener', 'Dom/Util', 'Ui/Dialog', 'Wolt
                        this._options = Core.extend({
                                // request data
                                data: {},
+                               contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
                                responseType: 'application/json',
                                type: 'POST',
                                url: '',
@@ -96,7 +97,9 @@ define(['Core', 'Language', 'Dom/ChangeListener', 'Dom/Util', 'Ui/Dialog', 'Wolt
                        
                        this._xhr = new XMLHttpRequest();
                        this._xhr.open(this._options.type, this._options.url, true);
-                       this._xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
+                       if (this._options.contentType) {
+                               this._xhr.setRequestHeader('Content-Type', this._options.contentType);
+                       }
                        this._xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
                        
                        var self = this;