我使用jQuery和JSON从数据库中获取数据 p>
$(“#openNotification”)。on('click',function(e)
{
ID =“a”;
$ .ajax(
{
url:“notificationDetail”,
type :“POST”,
data:
{
namesID:ID
},
dataType:“JSON”,
success:function(jsonStr)
{
$(“。processingNotification”)。 hide();
var jSonLength = jsonStr.length;
for(var i = 0; i< jSonLength; i ++)
{
var userAvatar = jsonStr [0] .userAvatar;
\ n var newrow =“< div class ='subNotification'>< img src ='assets / img / avatar /”+ userAvatar +“'/>< / div>”;
} \ n
$(“。opened_page”)。html(newrow);
}
});
});
code> pre>
HTML < / p>
&lt; div class =“opened_page”&gt;&lt; / div&gt;
code> pre>
点击 #openNotificati 在 code>我可以看到来自PHP的jSon数据 p>
但是当我 想要将数据显示到 .opened_page code>它只显示1个数据。 p>
div>