Make pagination work with AJAX