0
I am trying to realize the deletion and an item for this controller
send a code to view
0 or 1, but the JS function responsible for treating that return is always falling into the fail
with the following error.
error [Object Object] parsererror
Controller
if ($this->matricula_model->excluir($matricula) === true)
echo json_encode(['codigo' => '0']);
else
echo json_encode(['codigo' => '1']);
If the return is true (there was no deletion) returns 0, if not 1. In getJSON I needed to capture this 0 and 1 to show a message, but only get the error.
getJSON
$.getJSON($('#base-url').val() + '/matricula/excluir/' + sf, function(data) {
console.log( "success", data );
})
.fail(function(textStatus, errorThrown) {
console.log("error " + textStatus, errorThrown);
})
Added the header?
header('Content-Type: application/json');
– edson alves
Yes, it’s already set up.
– Guilherme Rigotti