Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.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
将Feefo JSON数组提取到Javascript中,显示为HTML列表_Javascript_Json - Fatal编程技术网

将Feefo JSON数组提取到Javascript中,显示为HTML列表

将Feefo JSON数组提取到Javascript中,显示为HTML列表,javascript,json,Javascript,Json,我现在正在学习Javascript和JSON,但我真的被这一切弄糊涂了 我试图从JSON数组中提取数据,我已经说到了这一点 $(function(){ var $reviews = $('#reviews'); $.ajax({ type: 'GET', url: "https://api.feefo.com/api/10/reviews/all?merchant_identifier=pub-insurance-4u-co-uk&fiel

我现在正在学习Javascript和JSON,但我真的被这一切弄糊涂了

我试图从JSON数组中提取数据,我已经说到了这一点

$(function(){
    var $reviews = $('#reviews');
    $.ajax({
        type: 'GET',
        url: "https://api.feefo.com/api/10/reviews/all?merchant_identifier=pub-insurance-4u-co-uk&fields=reviews.service.rating.rating,reviews.service.review,reviews.customer.display_name",
        success: function(reviews) {

        $.each(reviews, function(i, review) {
        $reviews.append('<li>name: '+ review.display_name +', review: '+ review.review + ', rating: '+ review.rating + '</li>');
    });
   }
 });
});
$(函数(){
var$reviews=$(“#reviews”);
$.ajax({
键入:“GET”,
url:“https://api.feefo.com/api/10/reviews/all?merchant_identifier=pub-保险-4u-co-uk&fields=reviews.service.rating.rating,reviews.service.review,reviews.customer.display_name“,
成功:职能(审查){
美元。每个(审查,职能(i,审查){
$reviews.append(“
  • 名称:”+review.display_name+”,review:“+review.review+”,评级:“+review.rating+”
  • ”); }); } }); });
    我现在似乎走不远了。我已经读过JSON.parse(),也许这就是我需要的。非常感谢任何帮助/建议,谢谢

    $(函数(){
    
    $(function(){
        var $reviews = $('#reviews');
        $.ajax({
            type: 'GET',
            url: "https://api.feefo.com/api/10/reviews/all?merchant_identifier=pub-insurance-4u-co-uk&fields=reviews.service.rating.rating,reviews.service.review,reviews.customer.display_name",
            success: function(reviews) {
            //console.log(reviews);
            $.each(reviews.reviews, function(i, review) {
            $reviews.append('<li>name: '+ review.customer.display_name +', review: '+ review.service.review + ', rating: '+ review.service.rating.rating + '</li>');
        });
       }
     });
    });
    
    var$reviews=$(“#reviews”); $.ajax({ 键入:“GET”, url:“https://api.feefo.com/api/10/reviews/all?merchant_identifier=pub-保险-4u-co-uk&fields=reviews.service.rating.rating,reviews.service.review,reviews.customer.display_name“, 成功:职能(审查){ //控制台日志(评论); 美元。每个(审查。审查,职能(i,审查){ $reviews.append(“
  • 名称:”+review.customer.display_name+”,review:“+review.service.review+”,rating:“+review.service.rating.rating+”
  • ”); }); } }); });
    记录对象并在控制台中查看它是很有帮助的。然后,您可以看到结构并打印您喜欢的内容

    我就是这么做的:) 以下是一个屏幕截图:

    这是小提琴:

    太棒了!!!这么简单。。。。非常感谢你的帮助!!我终于可以继续前进了!