doufang3001 2019-03-17 06:39
浏览 57

使用php调用AJAX时,滑动滑块不起作用

I'm using a slick slider. While I'm calling a HTML part which have slick slider using AJAX call it is not working. I've mentioned my code as below:

$(document).ready(function(){

        var year = $("#year").val();

        if(year == 'all'){


            $.ajax({
              method: 'post',
              url: 'helpData.php',
              data: {year:year},
              success: function(data){
                $("#helpData").html(data);
              }
          });
        }
    });

This is an AJAX call.

if ($(this).is(".slider3")){
      $(this).slick({
        dots: true,
    autoplay:true,
    autoplaySpeed:1500,
    prevArrow: false,
      nextArrow: false,
      });
    }

This code is for slick slider which is in another JS file which I already included.

<?php 
        foreach ($helpData as $hdata) { 
                    $heData = $help->getAllImg($hdata->heid); 
            ?>
            <div class="col-md-6">
            <div class="onePost">
                <div class="mySlider slider3">
                    <?php foreach( $heData as $himg ){ ?>
                    <div class="bannerSlider">
                        <img src="<?php echo SITE_URL; ?>/img/help/<?php echo $himg->photo;  ?>" class="img-responsive otherImages" />
                    </div>
                    <?php  } ?>
                </div>
                <a href="highlightpost.php?id=<?php echo $hdata->heid; ?>">
                    <p class="photoCaption">
                        <?php echo $hdata->title; ?>
                    </p>
                </a>
                <p style="float: right;">
                    <a href=""><i class="fas fa-share-alt"></i></a>
                </p>

            </div>
            </div>
            <?php } ?>

<?php } ?>

This is my helpData.php code which is called using AJAX.

  • 写回答

1条回答 默认 最新

  • douji6735 2019-03-17 06:51
    关注

    Try this,

    <?php
    
    $html='';
    
    foreach ($helpData as $hdata) {
        $heData = $help->getAllImg($hdata->heid);
        $html .=     '<div class="col-md-6">
            <div class="onePost">
                <div class="mySlider slider3">';
       foreach ($heData as $himg) { 
           $html .='<div class="bannerSlider">
                            <img src="'.SITE_URL.'/img/help/'.$himg->photo.'" class="img-responsive otherImages" />
                        </div>';
        }
         $html .='</div>
                <a href="highlightpost.php?id='.$hdata->heid.'">
                    <p class="photoCaption">'.$hdata->title.'</p>
                </a>
                <p style="float: right;">
                    <a href=""><i class="fas fa-share-alt"></i></a>
                </p>
    
            </div>
        </div>';
    }
    
    echo $html;
    
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测