Add default Accept header for XHR

By default we're expecting JSON, so it should be "application/json, text/*"
This commit is contained in:
Artem Salpagarov 2014-09-19 22:18:06 +04:00
parent 638bc1feb1
commit 5b918c9760

View file

@ -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