dimanche 29 mai 2016

Action refuses to return the boolean value

I have the standard destroy action:

public function destroy($id)
{
    return Quiz::find($id)->delete();
}

Which is accessed by the following AJAX call:

// The CSRF token is included automatically!
$.ajax({
    url: /quiz/10,
    type: 'POST',
    data: {_method: 'DELETE'},
    success: function(response){
        if(response){
            // do stuff..
        }
    }
});

The problem

When the AJAX call is made, chrome console shows the following error:

enter image description here

Strange thing is, that everything works if I remove the return, but I need the status code to be returned. Can somebody explain why is this happening? Or, at least, how to debug this problem?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire