Add default Accept header for XHR
By default we're expecting JSON, so it should be "application/json, text/*"
This commit is contained in:
parent
638bc1feb1
commit
5b918c9760
1 changed files with 3 additions and 0 deletions
|
|
@ -847,6 +847,9 @@ Mithril = m = new function app(window, undefined) {
|
||||||
if (options.serialize == JSON.stringify && options.method != "GET") {
|
if (options.serialize == JSON.stringify && options.method != "GET") {
|
||||||
xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8")
|
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") {
|
if (typeof options.config == "function") {
|
||||||
var maybeXhr = options.config(xhr, options)
|
var maybeXhr = options.config(xhr, options)
|
||||||
if (maybeXhr != null) xhr = maybeXhr
|
if (maybeXhr != null) xhr = maybeXhr
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue