我正在尝试使用$.getJSON
检索的值在类下设置特定元素。问题是没有为元素显示任何内容。这是我的代码:
$.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);
});
和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>
我是否使用正确的jQuery功能来执行此操作?
任何帮助将不胜感激
由于