I am trying to call an API and display the data which is in the form of list, the problem I am facing is I am able to split the list and display it in HTML page, but I need to display appropriate label against the data. Any help in this regard is much appreciated. Thank you.
The data I got from API call is:
[[236,1,"1537890525704.jpg","","Residential","Rent",1200],
[235,1,null,"","Residential","Rent",10000]]
The way I've displayed data on my HTML page is:
The way I want to display is appropriate label against the data, Ex:
Property Id : 236
No. of Bedrooms: 1
Property Type : Residential
and so on..
client.html
<html>
<head>
<title>Test client application</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="cleint.js"></script>
<style>
.card {
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
transition: 0.3s;
width: 40%;
}
.card:hover {
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2);
}
.container {
padding: 2px 16px;
}
</style>
</head>
<body>
<p id="msgs" class="card container"></p>
client.js
$(document).ready(function() {
$.ajax({
url: "http://192.168.1.5:8000/fetch",
success: function(data){
var c=data;
}
}).then(function(data) {
var text = "";
var res = "";
var i;
for(var i=0; i<data.length; i++){
var prop = data[i];
for(var j=0;j<prop.length;j++){
$('#msgs').append($('<div>').text(prop[j]));
}
}
});
function display(str) {
$('#msgs').append($('<div>').text(str));
}
});
