JQuery - Cycle a class with timer and load remote content
I have look at the code below ( // JQuery - Cycle a class with timer)
and it runs nicely while c开发者_开发知识库hange the color of the active class with the the updated content from time13.php I would like be able to send and id to the remote file ( ie : get_inventory.php?o='+id , id is the id-number of my items in my inventory that change very rapidly) , and put the content into the class. this way I would be able to give update inventory to the users.
any help would be appreciated
li.active {
color: #f00;
}
// https://stackoverflow.com/questions/4553204/jquery-cycle-a-class-with-timer
toggleSlide = function() {
var active = $("#slider ul li.active");
var next = active.next();
if (next.length === 0) {
next = $('#slider ul li:first');
}
active.removeClass('active');
// with affects next.fadeOut('slow').addClass('active').load('time13.php').fadeIn('slow');
next.addClass('active').load('time13.php').fadeIn('slow');
}
setInterval(toggleSlide, 2000);
<div id="slider">
<ul>
<li class='active'> a </li>
<li> b </li>
<li> c </li>
<li> d </li>
<li> e </li>
</ul>
</div>
I would use ajax to call the data then put the content of what you are trying to extract from the php file.
$(document).ready(function(){
$.ajax({
type: "GET",
url: "time13.php",
success: function(data) {
$('li.active').html(data);
},
error: function(){
alert('There was a error');
}
});
});
精彩评论