在我的应用程序中,我有此代码。我注意到,内容类型无法发送。你知道如何强制发送吗?
$.ajax({
crossDomain: true,
type: 'GET',
url: 'http://serv/services/rest/contact/' + localStorage.getItem('contact'),
callback: 'jsonpCallback',
jsonpCallback: 'jsonpCallback',
jsonp: '_jsonp',
**contentType: 'application/json',**
dataType: 'jsonp json',
timeout : 10000,
success: function(data){
$("#name").attr("value", data.response.label);
} },
error: function (xhr, ajaxOptions, thrownError){
alert("Status: " + xhr.status + ", Ajax option: " + ajaxOptions + ", Thrown error: " + thrownError);
},
});
我的请求标头是:
Accept:*/*
Accept-Charset:ISO-8859-2,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:pl-PL,pl;q=0.8,en-US;q=0.6,en;q=0.4
Connection:keep-alive
Cookie:JSESSIONID=F0ED33279488888888B35A731B40EE0C; oam.Flash.RENDERMAP.TOKEN=789456321
Host:serv
User-Agent:Mozilla/5.0 (Windows NT 6.0) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.83 Safari/537.1
正如我所说,缺少 contentType。我错过了什么?
感谢帮助。