I'm trying to create an ajax search function, where user is to enter the search criteria, then ajax grab those data and send them to php to query the result from the database, then it returns the result along with the pagination link stored in a string.
In the javascript file:
$(document).ready(function(){
$('.song_filter').change(function(){
var url = 'listing/ctrl';
var data {
title: $('#title').val();
author: $('author').val();
}
$.post(url, data)
.success(result) {
var jsonObj = $.parseJSON( result );
output_list(jsonObj); /* fetch out the result */
}
});
});
And in my php listing/ctrl, I have both the query result and the paginated link ready to return. I have no problem returning only the query result on its own, but I don't know how to return both the result and the link.
$result = $this->pagination->get_result();
$page_nav = $this->pagination->page_nav(); // <li class="page">2</li><li class="page">3</li>
echo json_encode($result, JSON_UNESCAPED_UNICODE);