From 5b918c9760758ade818a6be8765008134b4fb155 Mon Sep 17 00:00:00 2001 From: Artem Salpagarov Date: Fri, 19 Sep 2014 22:18:06 +0400 Subject: [PATCH] Add default Accept header for XHR By default we're expecting JSON, so it should be "application/json, text/*" --- mithril.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mithril.js b/mithril.js index db6a2cb4..fb526e61 100644 --- a/mithril.js +++ b/mithril.js @@ -847,6 +847,9 @@ Mithril = m = new function app(window, undefined) { if (options.serialize == JSON.stringify && options.method != "GET") { xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8") } + if (options.deserialize == JSON.parse) { + xhr.setRequestHeader("Accept", "application/json, text/*"); + } if (typeof options.config == "function") { var maybeXhr = options.config(xhr, options) if (maybeXhr != null) xhr = maybeXhr