R
R
Ruslan Absalyamov2018-03-10 15:43:53
Laravel
Ruslan Absalyamov, 2018-03-10 15:43:53

Ajax gives an error The Response content must be a string or object implementing __toString(), "boolean" given?

I can not figure out how to save to the database with ajax. Everything seems to be fine, but for some reason this error comes out. The Response content must be a string or object implementing __toString(), "boolean" given. and I don't understand what to do with it, my implementation is in the
controller

public function store(Request $request)
    {
        Execute::created($request);
        return true;
    }

In the route
Route::get('/execute/create', '[email protected]');
Route::post('/execute/create', '[email protected]');

And when submitting ajax form
$('.form-create-execute').on('submit', function (e) {
        e.preventDefault();
        let form = $(this).serialize();
        console.log(form);
        $.post({
            data: form,
            url: 'http://localhost:8000/execute/create',
        }).done((res) => {
            console.log(typeof res);
            console.log(res)
        })
            .fail(error => console.log(error.responseJSON.message))
    })

Who can tell how to be here. Comes to the server string checked via gettype($request)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
JhaoDa, 2018-03-10
@rusline18

Who and where said that the controller method in Laravel can return a boolean value? The error directly states this.
I repeat once again - you need to carefully read error messages, documentation, google and think, and not write questions on the toaster in any sneeze. You can't become a normal programmer like that...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question