weixin_33736832 2016-02-02 18:13 采纳率: 0%
浏览 28

填充液体转盘

I know there are similar questions but I can't find answer for my problem. I am populating slider with data from database, but AJAX only puts first value in slider.

Here is my AJAX code:

$(document).ready(function() {
        $('#myNavbar > ul > li ').click(function(){ 
        var data=$(this).text();
        add(data);

        });
        function add(data) {
    var xmlhttp;

        if (window.XMLHttpRequest) {
            // code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
        } else {
            // code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange = function() {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                document.getElementById("slider").innerHTML=xmlhttp.responseText;
            }
        }
        xmlhttp.open("GET","php/add.php?data="+data,true);
        xmlhttp.send();
        }

    });

Here is my code for the slider in my HTML page:

    <div class="w3-third">
  <div id="liquid1" class="liquid">
    <span class="previous"></span>
    <div class="wrapper">
        <ul id="slider">

        </ul>
    </div>
   <span class="next"></span>
</div>
</div>

And here is my PHP code:

 <?php 

                     $conn=mysqli_connect("localhost","root","","iptv");
                        if (mysqli_errno($conn)) {
                            die("Neuspjela konekcija: " . mysqli_connect_error());

                    }
                else{
                    $cat=$_GET['data'];
                    $query='SELECT * FROM stream WHERE Kategorija="'.$cat.'"';
                    $all=mysqli_query($conn,$query);

                    if(!$all)echo'greska je "'.mysqli_error($conn).'"';

                    $contentPC = "";

                    while(($row = mysqli_fetch_assoc($all)) != NULL) {

                          $contentPC .= "<li><div class=/"tv/"><a href='javascript:changeVideoJW(\"".addcslashes($row['Link'],'"')."\");'>".addcslashes($row['Naziv'],'"')."</a></div></li>";


                        }


           mysqli_close($conn);
             echo $contentPC;
                }
?>

Ajax puts only first value from query in slider. The slider I'm using is the jQuery Liquid Carousel plugin. How do I make this work properly?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥25 matlab数值溢出该怎么解决?
    • ¥15 大家帮我看看为什么错了
    • ¥15 unity互动琴弦抖动效果
    • ¥15 做了个的二极管反向饱和电流测量电路,但是测试达不到效果
    • ¥15 nginx无证书访问https失败
    • ¥15 树莓派启动AP热点传入数据
    • ¥15 multisim中关于74ls192n和DSWPK开关的问题(相关搜索:计数器)
    • ¥15 在误装Windows server2019 后如何利用Windows.old恢复?
    • ¥20 代码实现状态连接包过滤防火墙的设计与实现
    • ¥15 vscode的红色箭头爆红和has no default export报错