JQuery.datatables只刷当前页面表格数据,保留分页页码

JQuery.datatable无刷新多种初始化表格的使用方式。
ajax.reload( callback, resetPaging )
里面有二个参数:
callback :当服务器返回数据并重绘完毕时执行此回调方法,回调方法返回的是服务器返回的数据
resetPaging: 重置(默认或者设置为true)或者保持分页信息(设置为false)

var table = $('#example').DataTable( {
	ajax: "data.json"
});

做数据处理的时候,执行某个方法,会重新reload()

$.ajax({
	type: "post",
	url: "edit",
	data: {id: data.id},
	async: true,// 默认:true为异步请求
	dataType: "json",
	success: function (data) {
		if (data.type == 'success') {
			tableData.ajax.reload();//会重载所有接口数据,返回到第一页
		} else {
			alert(data.msg);
		}
	}
});

重新加载表数据(分页留存);

$.ajax({
	type: "post",
	url: "edit",
	data: {id: data.id},
	async: true,// 默认:true为异步请求
	dataType: "json",
	success: function (data) {
		if (data.type == 'success') {
			tableData.ajax.reload(null, false);//如果在方法里传二个参数,重新加载表数据(分页页码保留);
		} else {
			alert(data.msg);
		}
	}
});
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值