JSON - Show all JSON data with jQuery

0 votes
216 views
added Jul 25, 2019 in API by LC Marshal Captain (25,790 points)
<link rel="stylesheet" href="style.css">
<script
  src="https://code.jquery.com/jquery-3.4.1.min.js"
  integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
  crossorigin="anonymous"></script>

<div id="app"></div>

<script>
$.ajax({
    url: "https://raw.githubusercontent.com/RichmondDay/public/master/test_vehicle_inventory_data.json",
    method: "GET",
    dataType: 'json',
    success: function(data) {
        console.log(typeof(data));
        var appendData = '';
        $.each(data, function(i, item) {
          appendData +=
        '<div class="col-12 mb-3"><p>' +
        item.Name + '<br>' +  item.Price + '<br>' + item.Retailer + '<br>' + item.Kilometres + '<br>' + item.Transmission + '<br>' + item.Exterior + '<br>' + item.Interior + '<br>' + item.VIN + '<br>' + item.DriveTrain
        '</p></div>';
        });
        $("#app").html(appendData);
    },
    error: function() {
        console.log(data);
    }
});
</script>

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...