I'm trying to format what new comments look like on a Wordpress comment list, using Ajax. This is the snippet I'm working on.
The full piece can be found here: http://pastebin.com/UHnPgf4J
success: function(data, textStatus){
if(data=="success"){
var avatar = <?php echo get_avatar( $comment, 32 ); ?>;
var author = <?php the_author_meta( 'user_url'); ?>;
var timestamp = <?php printf(__('%1$s at %2$s'), get_comment_date(), get_comment_time()) ?>;
var commenttext = jQuery('#comment').val();
jQuery('<li>'+'<div class="comment-author vcard">'+avatar+
'<div class="comment-meta">'+author+'</div>'+
'<div class="comment-time-stamp">'+timestamp+'</div>'+
'<div class="comment-text">'+commenttext+'</div>'+'</li>'+).insertBefore(respond);
statusdiv.html('<p class="ajax-success" >Thanks for your comment. We appreciate your response.</p>');
}
The only one that works is "commenttext" because it doesn't have php. The others ("avatar" "author" and "timestamp") all come back with errors in Firebug.
I tried some suggestions I found, but couldn't get any to work. Any help would be appreciated.