Json Parsing html

Json Parsing html

本文关键字:html Parsing Json      更新时间:2023-09-26

我有这个json,我想解析它。

我使用此代码,但它不起作用...我的错误在哪里?

<!doctype html>
<html>
<head>
    <title>Parsing</title>
</head>
<body>
    <script>
       $.getJSON('http://ciao.php', { get_param: 'value' }, function(data) {
    $.each(data, function(index, element) {
         $('body').append($('<p>').html('Nr : '+ Nr));
    });
});
    </script>
</body>
</html>

你的错误在这里:

$('body').append($('<p>').html('Nr SAT: '+ Nr SAT));

Nr SAT 不是 JavaScript 变量。您可以从请求访问 JSON,如下所示:

$.getJSON('http://sath3g.altervista.org/index.php', { get_param: 'value' }, function(data) { 
     $('body').append($('<p>').html('Nr SAT: '+ data["Nr SAT"]));
});

我同意 CornéM 的观点,但你写道:

<head>
    <title>Parsing</title>
</head>

您是否在真实脚本中实现了jQuery?否则它一定是问题的一部分;)