相同的代码和功能在LOCALHOST上正常工作,没有任何错误。但在我的在线服务器上,我收到上述错误消息。
所以这是我的代码细节
在控制器中这是代码:
public function listproduct(){
$table = 'fc_products';
$primaryKey = 'id';
$columns = array(
array( 'db' => 'code', 'dt' => 0 ),
array( 'db' => 'name', 'dt' => 1 ),
array( 'db' => 'category', 'dt' => 2 ),
array( 'db' => 'description', 'dt' => 3 ),
array( 'db' => 'tax', 'dt' => 4 ),
array( 'db' => 'price', 'dt' => 5,
'formatter' => function($d, $row ) {
return $ret = number_format((float)$d, $this->setting->decimals, '.', '').' '.$this->setting->currency;
}
),
array( 'db' => 'photo', 'dt' => 6 ,
'formatter' => function( $d, $row ) {
$action ='<div class="btn-group">';
$yesiam = label('yesiam');
$areyousure = label('Areyousure');
$viewproduct = label('Viewproduct');
$edit = label('Edit');
$modifyStock = label("ModifyStock");
$viewImage = label("ViewImage");
$printBarcodes = label('printBarcodes');
$row_id = $row['id'];
$row_color = $row['color'];
$row_code = $row['code'];
if($this->user->role === "admin"){
$action .="<a class=\"btn btn-default\" href=\"javascript:void(0)\" data-toggle=\"popover\" data-placement=\"left\" data-html=\"true\" title='$areyousure' data-content=\"<a class= 'btn btn-danger' href='products/delete/{$row_id}'>$yesiam</a>\"><i class='fa fa-times'></i></a>";
}
$action .="<a class=\"btn btn-default\" href=\"javascript:void(0)\" onclick=\"Viewproduct($row_id)\"><i class=\"fa fa-file-text\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"$viewproduct\"></i></a>";
$action .="<a class=\"btn btn-default\" href=\"products/edit/$row_id\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"$edit\"><i class=\"fa fa-pencil\"></i></a>";
if($this->user->role === "admin" && $row['type'] === 0 ){
$action .= "<a class=\"btn btn-default\" href=\"javascript:void(0)\" onclick=\"modifystock($row_id)\"><i class=\"fa fa-tasks\" data-toggle=\"tooltip\" data-placement=\"top\" title='$modifyStock'></i></a>";
}
if($d){
$action .= "<a class=\"btn $row_color white open-modalimage\" data-id=\"$d\" href=\"\" data-toggle=\"modal\" data-target=\"#ImageModal\"><i class=\"fa fa-picture-o\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"$viewImage\"></i></a>";
}
$action .= "<a class=\"btn btn-default\" href=\"javascript:void(0)\" data-toggle=\"modal\" data-target=\"#barcode\" onclick=\"productBcode = $row_code\"><i class=\"fa fa-barcode\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"$printBarcodes\"></i></a>";
$action .= "</div>";
/*$action = "<div class=\"btn-group\">
<a class=\"btn btn-default\" href=\"javascript:void(0)\" data-toggle=\"popover\" data-placement=\"left\" data-html=\"true\" title=\"\" data-content=\"<a class="btn btn-danger" href="products/delete/11597">Yes, delete it!</a>\" data-original-title=\"Are you sure ?\"><i class=\"fa fa-times\"></i></a></div>";
*/
return $action;
}
),
array( 'db' => 'color', 'dt' => 7 ),
array( 'db' => 'id', 'dt' => 8 ),
array( 'db' => 'type', 'dt' => 9 ),
);
$this->load->database();
// SQL server connection information
$sql_details = array(
'user' => $this->db->username,
'pass' => $this->db->password,
'db' => $this->db->database,
'host' => $this->db->localhost
);
require( 'traits/ssp.class.php');
echo json_encode(
SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )
);
exit();
}
public function loadProducts(){
$offset = $this->input->post('offset');
$products = Product::find('all', array('limit'=>200,'offset'=>$offset));
require( 'traits/load.php');
exit();
//$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();
}
});
} );