Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 74268

I have to create a webpage and load data from (eg mytestdata.com) in different div. There are multiple data in array products. Please help me

$
0
0

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


Viewing all articles
Browse latest Browse all 74268

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>