Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Ligonsker's avatar

Ajax and DB update return types

Hello

If I have an ajax call to some method in my controller, which updates the DB, what is a proper way to return the status to the frontend?

do you return response(...) with the correct code? Or something else?

thanks

0 likes
2 replies
vincent15000's avatar

If you need to customize the returned message, you can do that.

Otherwise I think it's not necessary because Laravel returns automatically the correct code. That's what I notice with my API methods.

1 like
aleahy's avatar

If you want to be explicit, you could do return response()->noContent(); which will provide a 204 status code for a successful update.

2 likes

Please or to participate in this conversation.