解析文件時,我不明白什麼地方出了錯:語法錯誤:JSON解析錯誤:意外的標識 「對象」(匿名函數)
{ "t": -9.30, "p": 728.11, "h": 87.10 }
javascript代碼:
<script type="text/javascript">
function check() {
$.get("http://....file.json", function(response, status, xhr) {
if (status == "success") {
var json = JSON.parse(response);
$("#temp").html(json.t + "°");
$("#pressure").html(json.p + " mm hg");
}
if (status == "error") {
$("#temp").html("error");
}
});
}
我收到錯誤:
SyntaxError: JSON Parse error: Unexpected identifier "object"
console.log(response); ? –
你不需要解析 – anand4tech
謝謝大家,問題解決了 – aspire89