2

我在使用下面的 ajax 请求时出错。

$.ajax({
    url: "http://webservice.users.com:8000/users",
    dataType: 'jsonp',
    beforeSend: function (xhr) {
        xhr.setRequestHeader("Authorization", "Basic b2d1e77hbi5lcmVu1BhczRVYg");
    },
    success: function (json) { console.log(json); },
    error: function (httpReq, status, exception) {
        console.log(status + " " + exception);
    }
});

我的调用是跨域的,结果是 text/html(可能 jquery 无法将结果转换为 application/json)

控制台错误:parsererror 错误:jQuery18206287364205345511_1351595013388 未调用错误: chrome 浏览器中的“SyntaxError: Unexpected token :”

Chrome 开发者工具服务响应头:

Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection:Keep-Alive
Content-Encoding:gzip
Content-Length:180
Content-Type:text/html
Date:Tue, 30 Oct 2012 10:36:57 GMT
Expires:Thu, 19 Nov 1981 08:52:00 GMT
Keep-Alive:timeout=15, max=100
Pragma:no-cache
Server:Apache/2.2.16 (Debian)
Set-Cookie:active_style=style; expires=Wed, 30-Oct-2013 10:36:57 GMT
Vary:Accept-Encoding,User-Agent

服务器响应正文:

{
    "data": {
        "islogin": "0"
    },
    "userdata": {
        "login": "0"
    },
    "rstatus": {
        "status": "0",
        "errno": "5555",
        "mesg": "blablabla"
    }
}
4

0 回答 0