I have a json like below
[
{"label":"Finder1","count":3},
{"label":"Finder2","count":1},
{"label":"Finder1 & Finder2","count":1}
]
I want to show the data in frontend in span tag. for ex:
Finder1 (3)
Finder2 (1)
Finder1 & Finder2 (1)
I have a json like below
[
{"label":"Finder1","count":3},
{"label":"Finder2","count":1},
{"label":"Finder1 & Finder2","count":1}
]
I want to show the data in frontend in span tag. for ex:
Finder1 (3)
Finder2 (1)
Finder1 & Finder2 (1)
Try this:Loop through the data and construct the desired string with it.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
var counter = 0;
$(function(){
var arr=[
{"label":"Finder1","count":3},
{"label":"Finder2","count":1},
{"label":"Finder1 & Finder2","count":1}
];
var str='';
$.each(arr,function(index){
str=str+arr[index].label+" ("+arr[index].count+")<br>";
});
$("#data").html(str);
});
</script>
<body>
<span id="data"></span>
</body>