Prevent DataTables send Ajax request at first time
Prevent DataTables send Ajax request at first time
sunchaojin
Posts: 2Questions: 0Answers: 0
DataTables is very good. I have used it for many small projects. Reccently, I have a problem that DataTables always do ajax request for the server at ever time page load. I want when entering into page, datatables does not load data (through ajax ) from server . I want to control when to load data from server, for example, I could put a button on the page, and when clicking button, datatables then load data from server.
The following is my code. Through the lookup button, I can control when to request.But when the page refreshes, I hope table is empty and not to request.
.....
$(document).ready(function() {
var oTable =$('#example').dataTable({
"aLengthMenu": [[25, 50, 100,200,400 ,-1], [25, 50, 100,200,400 , "All"]] ,
"sPaginationType": "full_numbers",
"bJQueryUI": true,
"iDisplayLength": 50 ,
"bLengthChange": true,
"bProcessing" : true,
"bServerSide" : true,///////////////
"bFilter": false,
"bSort": false,
"sAjaxSource" : "channel_ChannelProvinceConversionRate_jsonJSON.action"
});//oTable
var clickHandler=function(){
parm=$("#form1").serialize();
var oSettings = oTable.fnSettings();
//oSettings.bProcessing=true;
oSettings.sAjaxSource="channel_ChannelProvinceConversionRate_jsonJSON.action?"+parm;
oTable.fnPageChange( 'first' );
};//clickHandler
});//
aa
bb
cc
dd
process....
The following is my code. Through the lookup button, I can control when to request.But when the page refreshes, I hope table is empty and not to request.
.....
$(document).ready(function() {
var oTable =$('#example').dataTable({
"aLengthMenu": [[25, 50, 100,200,400 ,-1], [25, 50, 100,200,400 , "All"]] ,
"sPaginationType": "full_numbers",
"bJQueryUI": true,
"iDisplayLength": 50 ,
"bLengthChange": true,
"bProcessing" : true,
"bServerSide" : true,///////////////
"bFilter": false,
"bSort": false,
"sAjaxSource" : "channel_ChannelProvinceConversionRate_jsonJSON.action"
});//oTable
var clickHandler=function(){
parm=$("#form1").serialize();
var oSettings = oTable.fnSettings();
//oSettings.bProcessing=true;
oSettings.sAjaxSource="channel_ChannelProvinceConversionRate_jsonJSON.action?"+parm;
oTable.fnPageChange( 'first' );
};//clickHandler
});//
aa
bb
cc
dd
process....
This discussion has been closed.