0

我使用 jquery ajax 做一个跨域请求工作:

$.ajax({
    type: 'get',
    url: 'http://someurl',
    dataType : "jsonp",
    jsonp: 'callback',
    success: function (data) {

    }
})

但出现错误:Uncaught SyntaxError: Unexpected token :

我的请求 json 数据就像:

{
    "status": "ok", 
    "info": {
        "book_count": 54, 
        "title": "recommended"
    }, 
    "books": [
        {
            "iap_price": "", 
            "book_category": "yippee_education", 
            "book_category_desc": "\u4e50\u8c5a\u65e9\u6559", 
        }
    ]
}

那么我的代码有什么问题?我该如何解决这个问题?

4

1 回答 1

0

如果此 JSON 已验证,我会收到错误消息:

{
    "status": "ok", 
    "info": {
        "book_count": 54, 
        "title": "recommended"
    }, 
    "books": [
        {
            "iap_price": "", 
            "book_category": "yippee_education", 
            "book_category_desc": "\u4e50\u8c5a\u65e9\u6559", 
        }
    ]
}

错误:

Parse error on line 11:
...                   }    ]}
----------------------^
Expecting 'STRING'

,结尾不要加逗号"book_category_desc": "\u4e50\u8c5a\u65e9\u6559",。那应该解决。

于 2012-10-10T04:57:55.340 回答