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!
Asked
Active
Viewed 26 times
0

Ahmed Ashour
- 5,179
- 10
- 35
- 56

Justinn Monton
- 17
- 4
-
check this question: http://stackoverflow.com/questions/5004978/check-if-page-gets-reloaded-or-refreshed-in-javascript – Hossam Mar 08 '17 at 08:18
-
I tried some of the answers but they wont work @Hossam – Justinn Monton Mar 08 '17 at 08:50
2 Answers
0
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 ...

Stefano Zanini
- 5,876
- 2
- 13
- 33
-
so can I use $_GET in that function and it will send it to the php file every reload? @Stefano – Justinn Monton Mar 08 '17 at 08:55
-
No, $_GET is the array where php stores the parameters sent in a get request. What you need to do in javascript is acutally making the get request to php, and how to do so depends on whether you want this task to be asyncronous or not. – Stefano Zanini Mar 08 '17 at 08:57
-
I suggest you have a look at jQuery (https://jquery.com/), which is a javascript library that can make this kind of stuff (and many more) a lot easier than with pure javascript. It has a .get() function that will be useful in your scenario (https://api.jquery.com/jquery.get/) – Stefano Zanini Mar 08 '17 at 08:59
0
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>

Walter Palladino
- 479
- 1
- 3
- 8