我有一個網頁調用時返回該JSON:jQuery的JSON解析錯誤
[{"id":"53","desc":"Roberts"}]
我使用這個jQuery的AJAX調用它:
$.ajax ({
url: rootPath + "data/topology/stations",
dataType: 'json',
data: { areaID: $("#lbxArea").val() },
success: function (data) {
// Use data for actions
},
error: function (jqXHR, textStatus, errorThrown) {
alert (textStatus);
alert (errorThrown);
}
});
我用螢火蟲來確認正在返回的數據是我放在頂部的。儘管如此,我落入error
回調,並第一次看到parsererror
在一個警告框,然後我看到
SyntaxError: JSON.parse: expected property name or '}'
我試圖讓服務回報
{"list":[{"id":"53","desc":"Roberts"}]}
但這並沒有改變任何東西。
可能重複的[jQuery不會解析我的JSON從AJAX查詢](http://stackoverflow.com/questions/249692/jquery-wont-parse-my-json- from-ajax-query) – sje397
您使用的是哪個版本的jQuery? – andyb
不,@ sje397,這看起來不像那個那個的重複。在這個問題中,JSON顯然是畸形的(沒有引用屬性名稱等)。這個問題中顯示的JSON看起來很好。 – Pointy