我需要有关如何在另一个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>
AND HERE 2 AJAX REQUEST
$(".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();
}
});
当一个类视频摄像机点击一个li a class = videoclick将出现..并且这完美...但是当我点击videoclick上的结果时... res_videoclick结果不会出现这个错误吗?请提前帮助我谢谢
答案 0 :(得分:0)
使用此
$(document).on('click',".videoclick",function(event)
而不是
$(".videoclick").bind('click',function(event)
答案 1 :(得分:0)
对逻辑进行一些修改:
$('#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);
}
});
});