From 062000de68ee11bd00388b3759fcf90fc4697e40 Mon Sep 17 00:00:00 2001 From: tangkikodo Date: Mon, 24 Apr 2017 11:29:22 +0800 Subject: [PATCH] add content-type: application/json; charset=utf-8 --- src/storage_manager/config/config.js | 7 ++++++- src/storage_manager/model/RemoteStorage.js | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/storage_manager/config/config.js b/src/storage_manager/config/config.js index 391e472ef..d753016e4 100644 --- a/src/storage_manager/config/config.js +++ b/src/storage_manager/config/config.js @@ -8,7 +8,7 @@ define(function () { autosave: 1, // Indicates if load data inside editor after init - autoload: 1, + autoload: 1, // Indicates which storage to use. Available: local | remote type: 'local', @@ -49,5 +49,10 @@ define(function () { //Callback after request onComplete: function(jqXHR, status){}, + // set contentType paramater of $.ajax + // true: application/json; charset=utf-8' + // false: 'x-www-form-urlencoded' + contentTypeJson: false + }; }); \ No newline at end of file diff --git a/src/storage_manager/model/RemoteStorage.js b/src/storage_manager/model/RemoteStorage.js index 8d9a3ade6..fae4fb487 100644 --- a/src/storage_manager/model/RemoteStorage.js +++ b/src/storage_manager/model/RemoteStorage.js @@ -11,6 +11,7 @@ define(['backbone'], params: {}, beforeSend: function(){}, onComplete: function(){}, + contentTypeJson: false }, /** @@ -32,7 +33,8 @@ define(['backbone'], complete: this.get('onComplete'), method: 'POST', dataType: 'json', - data: fd, + contentType: this.get('contentTypeJson') ? 'application/json; charset=utf-8': 'x-www-form-urlencoded', + data: this.get('contentTypeJson') ? JSON.stringify(fd): fd, }).always(function(){ if (typeof clb == 'function') { clb();