xuijs / xui

A tiny javascript framework for mobile web apps.
http://xuijs.com
789 stars 106 forks source link

Cannot customize Content-Type header on xhr() POST #66

Closed arkusuma closed 7 years ago

arkusuma commented 12 years ago

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" },
});
jerose commented 11 years ago

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.