PHP and JSON comment help..
Posted
by jay
on Stack Overflow
See other posts from Stack Overflow
or by jay
Published on 2010-06-16T08:20:36Z
Indexed on
2010/06/16
8:22 UTC
Read the original article
Hit count: 284
hi, guys
thanks for looking
my problem is that i cant seem to get jquery to display my generated data.
here is my JSON output
("posts":[{"id":"1-2","time":"0","name":"dash","avatar":"http:\/\/www.gravatar.com\/avatar\/9ff30cc2646099e31a4ee4c0376091b0?s=182&d=identicon&r=PG","comment":"rtetretrete tet rt uh utert"},{"id":"2-2","time":"0","name":"james","avatar":"http:\/\/www.gravatar.com\/avatar\/d41d8cd98f00b204e9800998ecf8427e?s=182&d=identicon&r=PG","comment":"fsdfdfsdf\r\n"}])
and here is my jquery
$(document).ready(function(){
var url="comments.php";
$.getJSON(url,function(json){
$.each(json.posts,function(i,post){
$("#content").append(
'<div class="post">'+
'<h1>'+post.name+'</h1>'+
'<p>'+post.comment+'</p>'+
'<p>added: <em>'+post.time+'</em></p>'+
'<p>posted by: <strong>'+post.name+'</strong></p>'+
'<p>avatar: <strong>'+post.avatar+'</strong></p>'+
'</div>'
); });
});
});
© Stack Overflow or respective owner