小编asp*_*e89的帖子

SyntaxError:JSON解析错误:意外的标识符"object"(匿名函数)

我不明白解析文件时出了什么问题:

{ "t": -9.30, "p": 728.11, "h": 87.10 }
Run Code Online (Sandbox Code Playgroud)

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 + "&deg;");
            $("#pressure").html(json.p + " mm hg");
        }
        if (status == "error") {
            $("#temp").html("error");
        }
    });
}
Run Code Online (Sandbox Code Playgroud)

我收到错误:

SyntaxError: JSON Parse error: Unexpected identifier "object"
Run Code Online (Sandbox Code Playgroud)

javascript jquery json

15
推荐指数
2
解决办法
6万
查看次数

标签 统计

javascript ×1

jquery ×1

json ×1