php - How do I send data using a refresh function in javascript and retrieve another data using the same refresh function

103

I'm really not good at technical terms (because I'm still a beginner) but I am developing a system as a school project. It's a mobile app (I used phonegap). my question is that I wanted to send data (preferably$_get) to a PHP page so that I can run my query with it. But I don't want a button or link to be a trigger. I want my trigger to be when the page reloads (or refreshes. Any idea or help is appreciated!

820

Answer

Solution:

You can do that with javascript, binding the action of sending data to your php page to the "document loaded" event.

With pure javascript you can do that with

<body onload="yourFunction();">

or

document.onload = function ...
607

Answer

Solution:

If you are working with PHP, you should create the HTML dynamically so, the information sent to the app will already contain the data when shown. A dirty example:<?php ?> <html> static html code <?php your content including dynamic data shown from your PHP backend ?> </html>

People are also looking for solutions to the problem: php - Trying to receive object in route - Laravel

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.