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

ajay01's avatar

Global Hook to apply loader for form submit using AJAX and PHP.

I working on pre-built websites and there some critical bug that I have to solve on that. In this laravel project at some places, we have used normal PHP form submit by giving POST route to the action. and on submit, the page is being reloaded. And for someplace they are using AJAX form submit where page load action is not performing.

Now, I have to apply the loader when some loading activity is being performed. like for normal PHP form submit it should show loader on submit and on AJAX form submit it also should show loader when form is being submitted. I'm Looking for some global hook so that I can apply the javascript at single blade file and it work for both. I don't want to go to each and every blade file and find out how the form is being submited. and apply javascript on every blade file. Is there any way?

0 likes
0 replies

Please or to participate in this conversation.