Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/441.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Json解析html_Javascript_Jquery_Json - Fatal编程技术网

Javascript Json解析html

Javascript Json解析html,javascript,jquery,json,Javascript,Jquery,Json,我有这个json,我想解析它 我使用这个代码,但它不工作。。。 我的错误在哪里 <!doctype html> <html> <head> <title>Parsing</title> </head> <body> <script> $.getJSON('http://ciao.php', { get_param: 'value' }, function(data)

我有这个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>

解析
$.getJSON('http://ciao.php“,{get_param:'value'},函数(数据){
$.each(数据、函数(索引、元素){
$('body').append($('').html('Nr:'+Nr));
});
});
您的错误如下:

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

我同意科尼姆的观点,但你写道:

<head>
    <title>Parsing</title>

</head>

解析

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

JavaScript错误控制台说什么?浏览器的开发者工具网络选项卡说什么?HTTP请求和响应是否符合预期?如果在回调函数中添加一些console.log语句,会发生什么情况?该函数是否运行过?
数据
是否包含您期望的数据?当你在
数据
上循环时,
索引
元素
是你期望的值吗?你没有注意到JS控制台中会报告的语法错误,并且通过Stackoverflow的语法突出显示变得明显吗?
+Nr SAT
肯定是错误的,我不明白……你能用某种方式解释一下这个问题吗更简单?…当然谢谢,您是否在
中添加了标签
?解析$.getJSON(“”,{get_param:'value'},函数(数据){$('body').append($('')).html('Nr SAT:'+data[“Nr SAT”]);});ciao我修复了代码。它不工作,但在控制台我没有一些错误。我要做的是??更正后,您的脚本是:
$(function(){$.getJSON('http://sath3g.altervista.org/index.php“,{get_param:'value'},函数(data){$('body').append($('').html('Nr SAT:''+data[“Nr SAT”]);console.log(data);})但您真正的问题是希望得到响应的站点,它说:XMLHttpRequest无法加载。请求的资源上不存在“Access Control Allow Origin”标头。因此,不允许访问源代码“null”。因此,如果它是您的页面,您需要允许从其他网站访问,否则请使用其他方法获取类似于PHP的JSON
<head>
    <title>Parsing</title>

</head>