From 5c1764ad234ccfd335b146e3d46155263dd32647 Mon Sep 17 00:00:00 2001 From: Mellisa Hankins Date: Thu, 11 Jul 2013 19:50:17 +1000 Subject: [PATCH] FIX: Reading response header instead of hacking to get json type --- javascript/GridFieldBulkManager.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/javascript/GridFieldBulkManager.js b/javascript/GridFieldBulkManager.js index fc3a86f..1aee0d9 100644 --- a/javascript/GridFieldBulkManager.js +++ b/javascript/GridFieldBulkManager.js @@ -135,15 +135,10 @@ type: "POST", context: $(this) }).done(function(r) { - // A bit hacky, but it checks if the response is json - try { - $.parseJSON(r); - - if(r.message) { - var msgType = r.messageType ? r.messageType : 'good'; - statusMessage(decodeURIComponent(r.message), msgType); - } - } catch(e) { } + if(xhr.getResponseHeader('content-type').indexOf('json') >= 0 && r.message) { + var msgType = r.messageType ? r.messageType : 'good'; + statusMessage(decodeURIComponent(r.message), msgType); + } $(this).parents('.ss-gridfield').entwine('.').entwine('ss').reload(); });