When trying to list the products I get an error, the funny thing is that locally it works very well but when doing the deploy it shows me the error "DataTables warning: table id = datatable - Ajax error For more information about this error, please see link " I will attach images of the problem with the code, if someone can guide me I appreciate it.
This is the code to list product.php:
<div class="table-responsive col-lg-12">
<table width="100%" class="table table-striped table-bordered table-hover" data-source="data-source" id="datatable">
<thead>
<tr>
<th>Id Product</th>
<th>Product Name</th>
<th>Supplier</th>
<th>Category</th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th>Price</th>
<th>Quantity</th>
<th>Photo</th>
<th></th>
<th>Actions</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
this other would be ajax_producto.js:
$( document ).ready(function() {
listar();
});
function listar() {
var table = $("#datatable").DataTable({
"order": [[0, "desc" ]],
"bFilter": true,
"bDestroy": true,
"sPaginationType": "full_numbers",
"ajax": {
"type": "POST",
"url": "../admin/list_.php"
},
"columns": [
{ "data": "productid"},
{ "data": "product_name"},
{ "data": "company_name"},
{ "data": "category_name"},
{ "data": "categoryid", "class":"hidden"},
{ "data": "company_address", "class":"hidden"},
{ "data": "contact", "class":"hidden"},
{ "data": "description", "class":"hidden"},
{ "data": "supplierid", "class":"hidden"},
{ "data": "tech", "class":"hidden"},
{ "data": "userid", "class":"hidden"},
{ "data": "video", "class":"hidden"},
{ "data": "product_price" },
{ "data": "product_qty"},
{ "data": "photo", render: getImg},
{ "data": "photo", "class":"hidden"},
{ "data": null,"defaultContent": "<div class='btns'><button class='btn btn-success btnEditar'><span class='fa fa-pencil'></span> Edit</button> | <button class='btn btn-danger btnEliminar'><span class='fa fa-trash'></span> Delete</button></div>"}
]
});
}
this would be list_.php:
<?php
include('session.php');
$pq = mysqli_query($conn,"select * from product left join category on category.categoryid=product.categoryid left join supplier on supplier.userid=product.supplierid");
$data["data"] = mysqli_fetch_all($pq,MYSQLI_ASSOC);
echo json_encode( $data );
?>
attached images.