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?