I have a page that uses google map api integration with a key and all. The thing is each time I load/reload the page I use 1 credit with the API. I need to insert things in the DB with a button on the page, but if I call a route with this button, I either exit the current page with the route or in my controller I redirect back or directly to the previous route, but in each of these cases I use an extra credit. Is there a solution ?
#Call a route without reloading the current page
7 messages · Page 1 of 1 (latest)
If you use an ajax request, you won't exit the current page.
Which frontend stack are you using?
I am using the Laravel blade as frontend the web site doesn't need to be really dynamic, not data change on select or smth like this, so I figured the Laravel built in frontend would be enough.
That's fine. Then you can add an event listener in JavaScript that uses axios to submit the data when the button is pressed.
I submit the data by calling the route in JS right ? What I mean is do I create the route, controller in php and with JS I call the route or I use JS and Ajax to insert in the db so without controller, route and all ?
If you have a normal store() route, just call that route from JavaScript with the data that it needs.