Ajax pagination issues
I have done ajax pagination in codeigniter. The entries are divided by 10, when I click the next page button, the page is automatically reloaded. In localhost the encoding works fine, but in the real server it doesn't work .... kindly help me .... This is my encoding:
<script>
var page_number=0;
var total_page =null;
var sr =0;
var sr_no =0;
var getReport = function(page_number){
if(page_number==0)
{
$("#previous").prop('disabled', true);
}
else
{
$("#previous").prop('disabled', false);
}
if(page_number==(total_page-1))
{
$("#next").prop('disabled', true);
}
else
{
$("#next").prop('disabled', false);
}
$("#page_number").text(page_number+1);
$.ajax({
url:"<?php echo base_url() ?>index.php/admin/pagination",
type:"POST",
dataType: 'json',
data:'page_number='+page_number,
success:function(data)
{
window.mydata = data;
total_page= mydata[0].TotalRows;
$("#total_page").text(total_page);
var record_par_page = mydata[0].Rows;
............ // here m getting the values
......... // here m getting the values
$.each(record_par_page, function (key, data)
{
sr =(key+1);
$(".tb").append('<tr class='+r_class+'><td class="no-print"><input type="checkbox" class="idRow chk_each" name="chk<?PHP echo $po_id; ?>" value="<?php echo $po_id; ?>" <?php echo set_checkbox('chk'.$po_id,$po_id); ?>> </td><td>'+data.created_date+'</td><td>........displaying values.........</td></tr>');
});
}
});
};
$(document).ready(function(e){
getReport(page_number);
console.log(sr);
$("#next").on("click", function(){
$(".tb").html("");
page_number = (page_number+1);
getReport(page_number);
console.log(sr);
});
$("#previous").on("click", function(){
$(".tb").html("");
page_number = (page_number-1);
getReport(page_number);
});
$("#search").on('keyup', function(){
var str = $.trim($(this).val());
search(str);
});
});
+3
Athi
source
to share
1 answer
As with previous discussions in the comment, the issue is raised because it does not suppress clcik fucntion. Solution for it useevent.preventDefault()
0
Anto king
source
to share