From 77c51d9a8abd51a40fe0d7798747b8ab7749f71e Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Sat, 22 Nov 2014 14:31:53 +0100 Subject: [PATCH] Added support for FormData in JS API facade --- public_html/js/Api.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/public_html/js/Api.js b/public_html/js/Api.js index 1bc45e17..63db4057 100644 --- a/public_html/js/Api.js +++ b/public_html/js/Api.js @@ -73,7 +73,7 @@ App.API = function(_, jQuery, promise, appState) { var xhr = null; var apiPromise = promise.make(function(resolve, reject) { - xhr = jQuery.ajax({ + var options = { headers: { 'X-Authorization-Token': appState.get('loginToken') || '', }, @@ -93,7 +93,12 @@ App.API = function(_, jQuery, promise, appState) { url: fullUrl, data: data, cache: false, - }); + }; + if (data instanceof FormData) { + options.processData = false; + options.contentType = false; + } + xhr = jQuery.ajax(options); }); apiPromise.xhr = xhr; return apiPromise;