I'm trying to set particular elements under a class with values retrieved via $.getJSON
. The problem is nothing is being shown for the elements. Here is my code:
$.getJSON('/members/feed/get-friend-status', function(data) {
$.each(data, function(i, item) {
$('.w3-container w3-card-2 w3-white w3-round w3-margin').find('h4').html(data[i].username);
$('.w3-container w3-card-2 w3-white w3-round w3-margin').find('p').html(data[i].status);
$('.w3-container w3-card-2 w3-white w3-round w3-margin').find('img').attr('src', data[i].images);
});
}).fail(function(response) {
console.log(response);
});
and the html:
<div class="w3-container w3-card-2 w3-white w3-round w3-margin">
<h4></h4>
<br>
<hr class="w3-clear">
<p></p>
<div class="w3-row-padding" style="margin: 0 -16px">
<div class="w3-half">
<img src="<?php echo $this->basePath(); ?>/images/lights.jpg" style="width: 100%" alt="Northern Lights" class="w3-margin-bottom">
</div>
</div>
<button type="button" class="w3-btn w3-theme-d1 w3-margin-bottom">
<i class="fa fa-thumbs-up"></i> Like
</button>
<button type="button" class="w3-btn w3-theme-d2 w3-margin-bottom">
<i class="fa fa-comment"></i> Comment
</button>
</div>
Am I using the right jQuery functionality to do this?
Any help would be appreciated
Thanks