javascript - How to display json data in a div when json data is in array -


"data": [     {      "name": "rehan",      "location": "pune",      "description": "hello hi",      "created_by": 13692,      "users_name": "xyz",     },     {       "name": "sameer",       "location": "bangalore",       "description": "how you",       "created_by": 13543,       "users_name": "abc",     }, 

the api contain more 100 data, how can display these data in html page. this:

name: rehan location: pune description: hello hi created by: 13692 user name: xyz 

how this?

   var data = [                     {                      "name": "rehan",                      "location": "pune",                      "description": "hello hi",                      "created_by": 13692,                      "users_name": "xyz",                     },                     {                       "name": "sameer",                       "location": "bangalore",                       "description": "how you",                       "created_by": 13543,                       "users_name": "abc",                     },                 ]              var htmltext = '';              ( var key in data ) {                 htmltext += '<div class="div-conatiner">';                 htmltext += '<p class="p-name"> name: ' + data[key].name + '</p>';                 htmltext += '<p class="p-loc"> location: ' + data[key].location + '</p>';                 htmltext += '<p class="p-desc"> description: ' + data[key].description + '</p>';                 htmltext += '<p class="p-created"> created by: ' + data[key].created_by + '</p>';                 htmltext += '<p class="p-uname"> username: ' + data[key].users_name + '</p>';                 htmltext += '</div>';             }              $('body').append(htmltext); 

this output to:

name: rehan location: pune description: hello hi created by: 13692 username: xyz  name: sameer location: bangalore description: how created by: 13543 username: abc 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -