Update Table after change select values Datatable
Update Table after change select values Datatable
![Danillo Leão Lopes](https://secure.gravatar.com/avatar/21be67bb613d61e4d653126846a67b2f/?default=https%3A%2F%2Fvanillicon.com%2F21be67bb613d61e4d653126846a67b2f_200.png&rating=g&size=120)
I'm try to update the table after change the select value, i got error: DataTables warning: table id=regrasimpostos - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1
// Document.Ready()
**let imposto = $("#imposto").dropdown("get value");
tabela_imposto = $("#regrasimpostos").DataTable({
"language": {
"url": host+"/js/Portuguese-Brasil.json"
},
"serverSide": true,
"ajax": `/pesquisa/regraimposto/${imposto}`,
"columns": [
{"data" : "impostoNome"},
{"data" : "modelo"},
{"data" : "pessoa"},
{"data" : "contribuinte"},
{"data" : "estado"},
{"data" : "cfop"},
{
"data" : null,
defaultContent: `<a href="#" title="Editar" data-id="impostoID" onclick="editarRegra('variavel')"><i class="edit icon"></i></a>`
}
]
})**
// AFTER CHANGE SELECT CALL
function pesquisaRegrasImpostos(imposto){
if (imposto != "") {
$.ajax({
url: /pesquisa/regraimposto/${imposto}
,
success: function(data){
tabela_imposto.ajax.url(data).load();
},
error: function(error){
alert(JSON.stringify(error));
}
});
}
}
// LARAVEL DATATABLES
**public function pesquisaRegraImpostoProduto(Request $request, $imposto)
{
return DataTables::of(ItensController::getRegrasImpostos($request, $imposto))->make(true);
}**
This question has an accepted answers - jump to answer
Answers
Did you follow the steps in the URL linked to in the error message?
http://datatables.net/tn/1
My guess is the issue is the URL you are trying to use in the success function:
What is the value of
data
?Kevin
oh man, really!
only it:
function pesquisaRegrasImpostos(imposto){
let url =
/pesquisa/regraimposto/${imposto}
;tabela_imposto.ajax.url(url).load();
}