简体   繁体   English

如何使用javascript中的刷新功能发送数据并使用相同的刷新功能检索其他数据

[英]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). 这是一个移动应用程序(我使用了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. 我的问题是我想将数据(最好是$_get )发送到PHP页面,以便可以使用它运行查询。 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. 您可以使用javascript来实现,将发送数据到php页面的操作绑定到“文档加载”事件。

With pure javascript you can do that with 使用纯JavaScript,您可以使用

<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. 如果使用的是PHP,则应动态创建HTML,这样,发送到应用程序的信息将在显示时已经包含数据。 A dirty example: <?php ?> <html> static html code <?php your content including dynamic data shown from your PHP backend ?> </html> 一个肮脏的例子: <?php ?> <html> static html code <?php your content including dynamic data shown from your PHP backend ?> </html>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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