这是我的表格代码,我不知道错误的人在哪里,显然错误是在javascript的第124行:
console.log(e.responseText)
但浏览器的控制台不显示错误,对不起我的英文不好。
JAVASCRIPT TABLE FUNCTION
function ListadoArticulos(){
var tabla = $('#tblArticulos').dataTable(
{ "aProcessing": true,
"aServerSide": true,
dom: 'Bfrtip',
buttons: [
'copyHtml5',
'excelHtml5',
'csvHtml5',
'pdfHtml5'
],
"aoColumns":[
{ "mDataProp": "id"},
{ "mDataProp": "1"},
{ "mDataProp": "2"},
{ "mDataProp": "3"},
{ "mDataProp": "4"},
{ "mDataProp": "5"},
{ "mDataProp": "6"},
{ "mDataProp": "7"},
{ "mDataProp": "8"},
{ "mDataProp": "9"},
{ "mDataProp": "10"},
{ "mDataProp": "11"},
{ "mDataProp": "12"},
{ "mDataProp": "13"},
{ "mDataProp": "14"},
{ "mDataProp": "15"},
{ "mDataProp": "16"},
{ "mDataProp": "17"},
{ "mDataProp": "18"},
{ "mDataProp": "19"},
{ "mDataProp": "20"}
],"ajax":
{
url: './ajax/ArticuloAjax.php?op=list',
type : "get",
dataType : "json",
error: function(e){
console.log(e.responseText);
}
},
"bDestroy": true
}).DataTable();
};
PHP
public function Listar(){
global $conexion;
$sql ="SELECT * FROM articulo";
$query = $conexion->query($sql);
return $query;
}
AJAX
case "list":
$query_Tipo = $objArticulo->Listar();
$data = Array();
$i = 1;
while ($reg = $query_Tipo->fetch_object()) {
$data[] = array("id"=>$i,
"1"=>$reg->idarticulo,
"2"=>$reg->cantidad,
"3"=>$reg->titulo,
"4"=>$reg->nombre,
"5"=>$reg->apellido,
"6"=>$reg->isbn,
"7"=>$reg->Editorial,
"8"=>$reg->Pais,///agregado para ver el error
"9"=>$reg->Categoria,///agregado para ver el error
"10"=>$reg->Costo,///agregado para ver el error
"11"=>$reg->Precio,///agregado para ver el error
"12"=>$reg->Pdescuento,///agregado para ver el error
"13"=>$reg->Total,///agregado para ver el error
"14"=>$reg->Ubicacion,///agregado para ver el error
"15"=>'<img width=100px height=100px src="./'.$reg->imagen.'" />',///agregado para ver el error
"16"=>$reg->Cbarra,///agregado para ver el error
"17"=>$reg->date,///agregado para ver el error
"18"=>$reg->Distribuidor,
'<button class="btn btn-warning" data-toggle="tooltip" title="Editar" onclick="cargarDataArticulo('.$reg->idarticulo.',\''.$reg->cantidad.'\',\''.$reg->nombre.'\',\''.$reg->apellido.'\',\''.$reg->Editorial.'\',\''.$reg->isbn.'\',\''.$reg->imagen.'\')"><i class="fa fa-pencil"></i> </button> '.
'<button class="btn btn-danger" data-toggle="tooltip" title="Eliminar" onclick="eliminarArticulo('.$reg->idarticulo.')"><i class="fa fa-trash"></i> </button>');
$i++;
}
$results = array(
"sEcho" => 1,
"iTotalRecords" => count($data),
"iTotalDisplayRecords" => count($data),
"aaData"=>$data);
echo json_encode($results);
break;
HTML 的
<table id="tblArticulos" class="table table-striped table-bordered table-condensed table-hover" cellspacing="0" cellpadding="0" width="100%">
<thead>
<tr>
<th>#</th>
<th>Idarticulo</th>
<th>Cantidad</th>
<th>Titulo</th>
<th>Nombre</th>
<th>Apellido</th>
<th>ISBN</th>
<th>Editorial</th>
<th>Pais</th>
<th>Categoria</th>
<th>Costo</th>
<th>Precio</th>
<th>Descuento</th>
<th>Total</th>
<th>Ubicacion</th>
<th>Imagen</th>
<th>Cbarra</th>
<th>Año</th>
<th>Ingresado</th>
<th>Distribuidor</th>
<th>Opciones</th>
</tr>
</thead>
<tbody id="articulo">
</tbody>
</table>
我不知道错误是什么,我花了很多时间在表格中查看我的数据,但没有显示任何内容。 表格和页面的一些图像: page
控制台的错误:
Articulo.js:124 Arguments(3)0: {readyState: 4, getResponseHeader: ƒ, getAllResponseHeaders: ƒ, setRequestHeader: ƒ, overrideMimeType: ƒ, …}1: "parsererror"2: SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at n.parseJSON (http://localhost/solventas2/public/js/jquery.min.js:4:5497)
at ub (http://localhost/solventas2/public/js/jquery.min.js:4:7521)
at x (http://localhost/solventas2/public/js/jquery.min.js:4:10935)
at XMLHttpRequest.<anonymous> (http://localhost/solventas2/public/js/jquery.min.js:4:14765)callee: ƒ (e)length: 3Symbol(Symbol.iterator): ƒ values()__proto__: Object