xuijs / xui

A tiny javascript framework for mobile web apps.

Home Page:http://xuijs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot customize Content-Type header on xhr() POST

arkusuma opened this issue · comments

My web service was strictly accepting request with Content-Type: application/json
I cannot get that kind of header in XUI. The code below always produce
Content-Type: application/x-www-form-urlencoded, application/json

Code:

x$("#result").xhr("/mobile.asmx/arsip", {
    method: "post",
    async: true,
    data: '{"hal": 1}',
    headers: { "Content-Type": "application/json" },
});

This means it wont work with Yahoo API's using direct OAuth since it requires a Content-Type of "application/json" on POST also. Would seem better to have "application/x-www-form-urlencoded" there only as a default content type on POST, but allow it to be overwritten.