Javascript DataTables警告:表id=tableProduct-JSON响应无效。有关此错误的详细信息,请参阅http://datatables.net/tn/1
相同的代码和功能在本地主机上正常工作,没有任何错误。但在我的在线服务器上,我收到了上面的错误消息。 下面是我的代码详细信息Javascript DataTables警告:表id=tableProduct-JSON响应无效。有关此错误的详细信息,请参阅http://datatables.net/tn/1,javascript,php,jquery,json,codeigniter-2,Javascript,Php,Jquery,Json,Codeigniter 2,相同的代码和功能在本地主机上正常工作,没有任何错误。但在我的在线服务器上,我收到了上面的错误消息。 下面是我的代码详细信息 在控制器中,这是代码: 公共函数列表产品(){ $table='fc_products'; $primaryKey='id'; $columns=数组( 数组('db'=>'code','dt'=>0), 数组('db'=>name','dt'=>1), 数组('db'=>'category','dt'=>2), 数组('db'=>'description','dt'=>3
在控制器中,这是代码: 公共函数列表产品(){
$table='fc_products';
$primaryKey='id';
$columns=数组(
数组('db'=>'code','dt'=>0),
数组('db'=>name','dt'=>1),
数组('db'=>'category','dt'=>2),
数组('db'=>'description','dt'=>3),
数组('db'=>'tax','dt'=>4),
数组('db'=>price','dt'=>5,
“格式化程序”=>函数($d,$row){
返回$ret=number_格式((float)$d,$this->setting->decimals,'.'','.''。$this->setting->currency;
}
),
数组('db'=>photo','dt'=>6,
“格式化程序”=>函数($d,$row){
$action='';
$yesiam=标签('yesiam');
$areyousure=标签('areyousure');
$viewproduct=标签('viewproduct');
$edit=标签('edit');
$modifyStock=标签(“modifyStock”);
$viewImage=标签(“viewImage”);
$printBarcodes=标签('printBarcodes');
$row_id=$row['id'];
$row_color=$row['color'];
$row_code=$row['code'];
如果($this->user->role==“admin”){
$action.=“\”>”;
}
$action.=”;
$action.=”;
如果($this->user->role==“admin”&&&$row['type']==0){
$action.=”;
}
如果($d){
$action.=”;
}
$action.=”;
$action.=”;
/*$action=”
\“数据原始标题=\”是否确定?\“>”;
*/
返回$action;
}
),
数组('db'=>'color','dt'=>7),
数组('db'=>'id','dt'=>8),
数组('db'=>'type','dt'=>9),
);
$this->load->database();
//SQL server连接信息
$sql\u details=数组(
'user'=>this->db->username,
'pass'=>this->db->password,
'db'=>this->db->database,
'host'=>this->db->localhost
);
要求('traits/ssp.class.php');
回声json_编码(
SSP::简单($\u GET、$sql\u details、$table、$primaryKey、$columns)
);
退出();
}
公共函数loadProducts(){
$offset=$this->input->post('offset');
$products=Product::查找('all',数组('limit'=>200,'offset'=>$offset));
要求('traits/load.php');
退出();
//$this->content_view='pos';
}
在js脚本中:
var tableProduct = $('#tableProduct').DataTable( {
'processing' : true,
'serverSide' : true,
'ajax' : 'index.php/products/listproduct',
//'ajax' : "<?php echo site_url('products/listproduct')?>/",
dom: 'T<"clear">lfrtip',
tableTools: {
"sSwfPath": "https://cdn.datatables.net/tabletools/2.2.4/swf/copy_csv_xls_pdf.swf",
'bProcessing' : true,
"aButtons": [
"xls",
{
"sExtends": "pdf",
"sPdfOrientation": "landscape",
"sPdfMessage": ""
},
"print"
]
},
drawCallback: function() {
$('[data-toggle="popover"]').popover();
}
});
} );
var tableProduct=$('#tableProduct')。数据表({
“处理”:正确,
“服务器端”:正确,
“ajax”:“index.php/products/listproduct”,
//“ajax”:“/”,
dom:'Tlfrtip',
表格工具:{
“sSwfPath”:https://cdn.datatables.net/tabletools/2.2.4/swf/copy_csv_xls_pdf.swf",
“bProcessing”:true,
“阿布顿”:[
“xls”,
{
“性倾向”:“pdf”,
“方向”:“景观”,
“sPdfMessage”:”
},
“打印”
]
},
drawCallback:function(){
$('[data toggle=“popover”]')。popover();
}
});
} );
请使用易于阅读的标题,并在结尾处重新格式化代码。请检查控制台中加载的JSON响应,并将其添加到您的问题中。这是来自服务器的JSON响应中的一个错误。
var tableProduct = $('#tableProduct').DataTable( {
'processing' : true,
'serverSide' : true,
'ajax' : 'index.php/products/listproduct',
//'ajax' : "<?php echo site_url('products/listproduct')?>/",
dom: 'T<"clear">lfrtip',
tableTools: {
"sSwfPath": "https://cdn.datatables.net/tabletools/2.2.4/swf/copy_csv_xls_pdf.swf",
'bProcessing' : true,
"aButtons": [
"xls",
{
"sExtends": "pdf",
"sPdfOrientation": "landscape",
"sPdfMessage": ""
},
"print"
]
},
drawCallback: function() {
$('[data-toggle="popover"]').popover();
}
});
} );