sample data in url
mytestdata.com
Products([{"id":"1","name":"ABC","details":"xyz"}
{"id":"2","name":"DEF","details":"uvw"}])
)
ajax call to load the data
$(function () {
jQuery.ajax({
url: "mytestdata.com",
type: "GET",
dataType: "jsonp",
}).success(function (result) {
});
});
function Products(data) {
for (var i in data) {
$('.itemid').html(data[i].id);
$('.itemname').html(data[i].name);
$('.itemdetails').html(data[i].details);
}}
html code to load the data
<div class="itemid"></div>
<div class="itemname"></div>
<div class="itemdetails"></div>
The issue with the code is data is loaded to html but just the last row of products in array is loaded
output of the code 2 def uvw