Search code examples
javascriptphphtmlfunctionpage-refresh

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!


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