I do not understand what went wrong when parsing file:
{ "t": -9.30, "p": 728.11, "h": 87.10 }
javascript code:
<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");
}
});
}
I receive error:
SyntaxError: JSON Parse error: Unexpected identifier "object"
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…