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;
相关文章:
- 我的响应菜单在移动版中不起作用
- Ajax:Ajax响应中的链接不起作用
- 带有 AJAX 响应或 AJAX 响应的 IF 条件.响应.Text 不起作用
- 如何让Webworker真正响应,以及为什么setTimeout()不起作用
- 在表中显示ajax响应不起作用
- jquery在调整大小时响应不起作用
- angularjs不起作用的Json响应
- 响应式导航栏不起作用,品牌变得一团糟
- jquery.click()在Ajax 403响应后不起作用
- XML http 响应不起作用
- JQUERY响应不起作用
- Ajax JSON响应不起作用
- Mockjax响应不起作用
- 设置jsp上的Ajax响应不起作用
- 内联onclick事件对ajax响应不起作用
- HTML5画布响应不起作用
- 在Safari中,XML响应不起作用
- 引导导航栏响应不起作用
- 包含视口元后引导响应不起作用
- Jquery中的Javascript函数响应不起作用