我需要关于如何在另一个ajax中返回和ajax结果的帮助。
这是我的html
<div id="res_videoclick">
<iframe class="laptopvideo" src="http://www.ustream.tv/embed/recorded/37579887?v=3&wmode=direct" scrolling="no" frameborder="0" style="border: 0px none transparent;">
</iframe>
</div>
<ul id="videomenu">
<li><a class="videocategory selected" href="HEARTLINK">HEARTLINK</a></li>
<li><a class="videocategory" href="WEIGHT LOSS: LEVEL 1">WEIGHT LOSS: LEVEL 1</a></li>
<li><a class="videocategory" href="GROCERY STORE FINDS">GROCERY STORE FINDS</a></li>
<li><a class="videocategory" href="TESTIMONIES">TESTIMONIES</a></li>
</ul>
<ul id="mycarousel" class="jcarousel-skin-tango">
<?php
$videos_query=mysql_query("select * from videos where category='HEARTLINK' order by category, title ASC" );
while($vd=mysql_fetch_array($videos_query))
{
$videosid = $vd['videosid'];
$title = $vd['title'];
$link = $vd['link'];
$linktwo = substr($link, 31, 2);
$linkfive = substr($link, 31, 5);
$linkfull = substr($link, 31, 8);
$category = $vd['category'];
$description = $vd['description'];
?>
<li><a class="videoclick" id="<?php echo $linkfull ;?>"><img style=" width:180px;;" src="http://static-cdn1.ustream.tv/videopic/0/1/<?php echo $linktwo ;?>/<?php echo $linkfive ;?>/<?php echo $linkfull ;?>/1_15835591_<?php echo $linkfull ;?>_320x240_b_1:2.jpg" alt="<?php echo $title;?>" title="<?php echo $title;?>" /></a></li>
<?php
}
?>
</ul>这里有2个AJAX请求
$(".videocategory").click(function()
{
$('#mycarousel').html('<small><img src="/travismartin/files/images/loading.gif" width="20" align="absmiddle"><br clear="all">Checking Database...</small>');
var videocategory = $(this).attr('href');
$.ajax({
type: "POST",
url: "/travismartin/files/ajax/ajax_change.php",
data: {videocategory:videocategory},
success: function(result)
{
$('#mycarousel').html(result);
}
});
});
$(".videoclick").bind('click',function(event)
{
$('#res_videoclick').html('<small><img src="/travismartin/files/images/loading.gif" width="20" align="absmiddle"><br clear="all">Checking Database...</small>');
var videoclick = $(this).attr('id');
$.ajax({
type: "POST",
url: "/travismartin/files/ajax/ajax_change.php",
data: {videoclick:videoclick},
success: function(result1)
{
$('#res_videoclick').html(result1);
$('html, body').stop().animate({
scrollTop: $("#res_videoclick").offset().top
}, 500);
event.preventDefault();
}
}); 当一个类视频录影器点击安莉,一个class=videoclick就会出现..效果很好..。但当我在视频上点击结果时..。res_videoclick结果不会出现什么问题?请提前帮我谢谢
发布于 2013-11-30 06:46:30
使用这个
$(document).on('click',".videoclick",function(event) 而不是
$(".videoclick").bind('click',function(event) 发布于 2013-11-30 06:47:03
对逻辑作了一些修改:
$('#mycarousel').hide();
$(".videocategory").click(function()
{
var videocategory = $(this).attr('href');
$.ajax({
type: "POST",
url: "/travismartin/files/ajax/ajax_change.php",
beforeSend: function() {
$('#mycarousel').html('<small><img src="/travismartin/files/images/loading.gif" width="20" align="absmiddle"><br clear="all">Checking Database...</small>');
},
complete: function() {
$('#mycarousel').hide();
},
data: {videocategory:videocategory},
success: function(result)
{
$('#mycarousel').html(result);
}
});
}); https://stackoverflow.com/questions/20297365
复制相似问题