raj*_*tsm 29 javascript ajax jquery datatables
是否可以在datatable ajax调用中成功调用javascript函数.这是我尝试使用的代码,
var oTable = $('#app-config').dataTable(
{
"bAutoWidth": false,
"bDestroy":true,
"bProcessing" : true,
"bServerSide" : true,
"sPaginationType" : "full_numbers",
"sAjaxSource" : url,
"fnServerData" : function(sSource, aoData, fnCallback) {
alert("sSource"+ sSource);
alert("aoData"+ aoData);
$.ajax({
"dataType" : 'json',
"type" : "GET",
"url" : sSource,
"data" : aoData,
"success" : fnCallback
});
}
Run Code Online (Sandbox Code Playgroud)
是否可能有类似的东西,
success : function(){
//.....code goes here
}
Run Code Online (Sandbox Code Playgroud)
而不是"成功":fnCallback ------>这是AJAX调用的最后一行.在这个函数中,我想检查从服务器端发送的值.在此先感谢任何帮助....
Jos*_*one 46
你可以使用dataSrc:
这是datatables.net的典型示例
var table = $('#example').DataTable( {
"ajax": {
"type" : "GET",
"url" : "ajax.php",
"dataSrc": function ( json ) {
//Make your callback here.
alert("Done!");
return json.data;
}
},
"columns": [
{ "data": "name" },
{ "data": "position" },
{ "data": "office" },
{ "data": "extn" },
{ "data": "start_date" },
{ "data": "salary" }
]
} );
Run Code Online (Sandbox Code Playgroud)
Chr*_*ris 30
我找到的最好的方法是使用initComplete方法,因为它在检索数据后触发并呈现表.注意这只会发射一次.
$("#tableOfData").DataTable({
"pageLength": 50,
"ajax":{
url: someurl,
dataType : "json",
type: "post",
"data": {data to be sent}
},
"initComplete":function( settings, json){
console.log(json);
// call your function here
}
});
Run Code Online (Sandbox Code Playgroud)
Ana*_*afi 25
你可以用这个:
"drawCallback": function(settings) {
console.log(settings.json);
//do whatever
},
Run Code Online (Sandbox Code Playgroud)
Gia*_*nis 17
这对我来说效果很好。另一种方法效果不好
'ajax': {
complete: function (data) {
console.log(data['responseJSON']);
},
'url': 'xxx.php',
},
Run Code Online (Sandbox Code Playgroud)
小智 6
对于数据表1.10.12.
$('#table_id').dataTable({
ajax: function (data, callback, settings) {
$.ajax({
url: '/your/url',
type: 'POST',
data: data,
success:function(data){
callback(data);
// Do whatever you want.
}
});
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
77690 次 |
| 最近记录: |