Jquery 动态引导程序carousal不工作
我有一个动态引导转盘,它显示来自数据库的图像 一切正常,但有时旋转木马不会向左或向右移动,即使单击箭头按钮。但当我刷新页面时,效果很好 我的代码如下所示Jquery 动态引导程序carousal不工作,jquery,ajax,bootstrap-4,carousel,Jquery,Ajax,Bootstrap 4,Carousel,我有一个动态引导转盘,它显示来自数据库的图像 一切正常,但有时旋转木马不会向左或向右移动,即使单击箭头按钮。但当我刷新页面时,效果很好 我的代码如下所示 function show_gallary(id){ $.ajax({ url: "<?php echo base_url();?>home/fetch_gallary_modal/"+id,// url to your upload process file type: "POST",
function show_gallary(id){
$.ajax({
url: "<?php echo base_url();?>home/fetch_gallary_modal/"+id,// url to your upload process file
type: "POST",
dataType:'json',
contentType: false,
cache: true,
processData:false,// tell jQuery not to set contentType
success: function(data){
$(".events").empty();
var img = data[0].image.split(",");
$("#show_gallary").modal('show');
$("#gal_modal_description").html(data[0].description);
$("#gal_modal_header").html(data[0].name);
var cnt=img.length;
var k=1;
for(var i=0;i<cnt;i++){
var url="<?php echo base_url()?>gallery/"+img[i];
if(i==0){
$(".events").append('<div class="item active"><img style="width:50%;" id="gl'+k+'" src="'+url+'"></div>');
}
else{
$(".events").append('<div class="item"><img style="width:50%;" id="gl'+k+'" src="'+url+'"></div>');
}
k++;
}
}
});
}
函数显示(id){
$.ajax({
url:“home/fetch\u gallary\u modal/”+id,//上传过程文件的url
类型:“POST”,
数据类型:'json',
contentType:false,
是的,
processData:false,//告诉jQuery不要设置contentType
成功:功能(数据){
$(“.events”).empty();
var img=data[0]。image.split(“,”);
$(“show#u gallary”).modal(‘show’);
$(“#gal#u modal_description”).html(数据[0].description);
$(“#gal#u modal_header”).html(数据[0].name);
var cnt=img.长度;
var k=1;
对于(var i=0;i可能是的重复项,但不是修复项。我使用了.active类
<div id="myCarousel2" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel2" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel2" data-slide-to="1"></li>
<li data-target="#myCarousel2" data-slide-to="2"></li>
</ol>
<div class="carousel-inner events"></div>
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel2" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel2" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
<span class="sr-only">Next</span>
</a>
</div>