I am attempting to perform the deletion and an item, so in controller
I send a code to view
0 or 1 , but the JS function responsible for dealing this return is always falling in 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) it returns 0 , if not 1 . In getJSON I needed to capture this 0 and 1 to display a message, but I 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);
})