+ 1

How can you connect backend with frontend?

I want to make a website, and i wonder how you can get variables and other stuff from backend to frontend or reverse?

20th Jun 2020, 10:27 AM
Rok Hladin
2 Respuestas
+ 3
1. Inject them into your script in the backend. e.g in php echo <<<_JS <script> window.my_vars = $var; </script> _JS; This should not be used for private data like password. 2. To ensure privacy. You can call the backend script from frontend using ajax and work on the results in frontend. If you want to do that, search google for axios library or fetch api 3. You can use a service worker. The service worker can intercept http requests and perform logic between the backend and frontend. Not all browsers support service workers though 4. For things like extra form details you can use hidden inputs in html <input type="hidden">
20th Jun 2020, 10:35 AM
Ore
Ore - avatar
+ 1
Thank you
20th Jun 2020, 10:39 AM
Rok Hladin