【发布时间】:2015-01-19 21:13:29
【问题描述】:
我正在尝试使用 Ajax 格式化 Wordpress 评论列表中新 cmets 的外观。这是我正在处理的 sn-p。
完整的文章可以在这里找到: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>');
}
唯一有效的是“commenttext”,因为它没有 php。其他人(“头像”、“作者”和“时间戳”)都在 Firebug 中返回错误。
我尝试了一些我发现的建议,但都没有任何效果。任何帮助将不胜感激。
【问题讨论】:
-
尝试引用
<?PHP ... ?> -
未来:运行后在浏览器中查看源代码,看看JS中的语法是如何混乱的,然后修复它。
-
这个文件是被php处理的吗?