This should help you: AJAX Request Help for next/previous page
Live Example: http://jsfiddle.net/Jaybles/MawSB/
var currentPage=1;
loadCurrentPage();
$("#next, #prev").click(function(){
currentPage= ($(this).attr('id')=='next') ? currentPage + 1 : currentPage - 1;
if (currentPage==0)
currentPage=1;
else if (currentPage==101)
currentPage=100;
else
loadCurrentPage();
});
function loadCurrentPage(){
$('input').attr('disabled','disabled');
$('#displayResults').html('<img src="http://blog-well.com/wp-content/uploads/2007/06/indicator-big-2.gif" />');
$.ajax({
url: '/echo/html/',
data: 'html=Current Page: ' + currentPage+'&delay=1',
type: 'POST',
success: function (data) {
$('input').attr('disabled','');
$('#displayResults').html(data);
}
});
}
Html
<input id="next" type="button" value="Next" />
<input id="prev" type="button" value="Previous" />
<div id="displayResults" name="displayResults"></div>