We can use multiple plugins like wp-pagenavi or wp-paginate for implementing pagination for wordpress sites and making it ajax based using the following code: 

```
jQuery(document).ready(function(){
    // ajax pagination
    jQuery('#wp_page_numbers a').live('click', function(){ 

        var link = jQuery(this).attr('href');                   
        jQuery('#main').html('Loading'); 
        jQuery('#main').load(link+' #entries')
    });
}); // end ready function

```

Sometimes, there are some cases where we want to display results based on custom query (i.e fetching results from the tables other than wordpress default tables) on a page template. 

What is the best way for implementing pagination in this case?