简体   繁体   中英

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

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!

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 ...

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM