Monday, October 22, 2012

AJAX Pagination using jQuery and PHP with Animation



I have created an Ajax JQuery based pagination few months before which my users liked very much and there are thousands of downloads of that tutorial. So, I thought to create on another tutorial for pagination with some jquery effects to make stylish and attractive. Its animated loading of records using jquery animation. I hope you will like it very much as it looks nice.
Thanks !

 


 

Database




CREATE TABLE IF NOT EXISTS `records` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`message` text NOT NULL,
`image` varchar(200) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

--
-- Dumping data for table `records`
--

INSERT INTO `records` (`id`, `message`, `image`) VALUES
(1, 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry''s standard dummy text ever since the 1500s,', '1.png'),
(2, 'There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don''t look even slightly believable.', '2.png');



JQuery Code




$(document).ready(function(){

function showLoader(){

$('.search-background').fadeIn(200);
}

function hideLoader(){

$('.search-background').fadeOut(200);
};

$("#paging_button li").click(function(){

showLoader();

$("#paging_button li").css({'background-color' : ''});
$(this).css({'background-color' : '#006699'});

$("#content").load("data.php?page=" + this.id, hideLoader);

return false;
});

$("#1").css({'background-color' : '#006699'});
showLoader();
$("#content").load("data.php?page=1", hideLoader);

});



 

HTML




<div>

<div id="container">

<div class="search-background">
<label><img src="loader.gif" alt="" /></label></div>
</div>

<div id="paging_button">

<ul>
'.$i.'

';
}?&gt;
</ul>
</div>
</div>


No comments:

Post a Comment