Jquery中的Javascript函数响应不起作用


Javascript function response in Jquery not working

我有一个表单,使用ajax将评论发布到video_comment.php,然后在视频页面上显示评论。

这是我的jquery代码:
$("input[id*='post_video_playallcomment_']").livequery('click', function(event) {
    event.preventDefault();    
    var video_msg   = $("#post_message");
    var input_id    = $(this).attr('id');
    var id_split    = input_id.split('_');
    var video_id    = id_split[3];                    
    var comment     = $("textarea[id='video_comment']").val();
    var response_messages = '#video_response';        
    if ( comment == '' ) {
        video_msg.fadeIn();
        return false;
    }
    video_msg.hide();
    user_posting(response_messages, '<?php echo $lang['600']; ?>', 1);
    reset_chars_counter();
    $.post(base_url + '/video_comment.php', { video_id: video_id, comment: comment },
    function(response) {
        if ( response.msg != '' ) {
            $(response_messages).hide();
            user_posting(response_messages, response.msg);                    
            $("textarea[id='video_comment']").val('');
        } else {
            $(response_messages).hide();
            user_response(response_messages, '<?php echo $lang['587']; ?>');             
            $(".no_comments").hide();
            $("textarea[id='video_comment']").val('');
            var bDIV = $("#comments_delimiter");
            var cDIV = document.createElement("div");
            $(cDIV).html(response.code);
            $(bDIV).after(cDIV);
        }
    }, "json");
});                         

在video_comment.php中,这是响应。在视频页面上显示评论的代码。

echo 'text...
echo '<div id="commentplayer"></div>';
echo '<script type="text/javascript">';
echo 'jwplayer("commentplayer").setup({';
echo 'file: "...url",';  
echo 'width: "300",';
echo 'height: "225",';
echo 'provider: "http",';
echo 'startparam: "start",';
echo 'wmode: "transparent",';        
echo 'controls: "true",'; 
echo 'stretching: "uniform",';    
echo 'primary: "flash",';       
echo 'autostart: "false",';
echo 'ga: {}';
echo '});';
echo '</script>';
echo 'text...

我没有问题得到'text…',但我无法让''在视频页面上显示。

帮助请…

而不是在php返回javascript代码,为什么不把它放在.post响应?

$("input[id*='post_video_comment']").click(function() {           
$.post('video_comment.php', function(response) {
  $('#comment').html(response.code);  
    //place javascript code here
}, "json");

});

或在js代码前放置onload

$str = '<div id="commentplayer"></div>
<script type="text/javascript">
window.onload=(function() {
    jwplayer("commentplayer").setup({
    file: "...url",
    width: "300",
    height: "225",
    provider: "http",
    startparam: "start",
    wmode: "transparent",      
    controls: "true", 
    stretching: "uniform",  
    primary: "flash",     
    autostart: "false",
    ga: {}
    });
});
</script>';
echo $str;