PHP:显示“正在加载”执行 php 脚本时的页面

发布于 2024-09-25 07:59:34 字数 421 浏览 3 评论 0原文

这就是我现在所得到的...

我有一个网页,当访问该网页时,它会通过其开放 API 连接到 Surveygizmo.com,检索大量数据,然后将这些数据返回给我,以便在我的设备上进行处理。结尾。此过程大约需要 10-12 秒,在执行时,页面只是处于“正在加载”状态,并且我会看到一个空白页面。

这就是我想要发生的事情......

当访问同一个网页时,我希望它启动脚本执行并开始通过他们的 API 从 Surveygizmo.com 检索数据,就像我正在做的那样现在,但是当该进程正在运行时,我希望显示一个“结果正在加载”页面/消息,而不是空白的白页,然后一旦脚本执行完成并且所有结果都已返回并处理, “正在加载结果”页面/消息消失。

我对 php 和 javascript 非常熟悉,但还没有弄清楚这一点。任何有关此事的指导或建议将不胜感激。

谢谢!

Here is what I've got right now...

I have a web page that when accessed, it connects to surveygizmo.com via their open API, retreives a whole lot of data, and then returns that data to me for processing on my end. This process takes roughly 10-12 seconds and while it is executing, the page just sits in the "loading" state and I'm shown a blank white page.

Here is what I want to happen...

When that same web page is accessed, I'd like it to kick off the script execution and begin retrieving the data from surveygizmo.com via their API in the same way I'm doing it now, but while that process is running, I would like there to be a "result are loading" page/message that is shown instead of the blank white page and then once the script execution finishes and all the results have been returned and processed, the "results are loading" page/message disappears.

I'm pretty familiar with php and javascript, but haven't been able to figure this one out yet. Any direction or advice on the matter would be greatly appreciated.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

素染倾城色 2024-10-02 07:59:34

您会想看看 AJAX。解决方案是向浏览器发送一个“正在加载”页面,其中包含显示加载消息的 javascript,然后异步连接到实际数据生成服务器端脚本。当您接收并处理数据后,您可以将其插入到 DOM 中并删除加载消息。谷歌搜索 XMLHttpRequest 将为您提供详细信息。

You'll want to take a look at AJAX. The solution is to send the browser a "loading" page, which contains javascript that shows the loading message, and then connects to the actual data generating server-side script asynchronously. When you have received and processed the data, you can insert it into the DOM and remove the loading message. Googling for XMLHttpRequest will get you the details.

清音悠歌 2024-10-02 07:59:34

创建一个显示您所需的加载消息的加载页面。然后使用ajax(我强烈推荐jQuery)加载一个单独的php文件来加载外部数据。一旦数据返回到您的加载页面,隐藏加载消息并将其替换为 ajax 的输出就是一个简单的任务。

Create a loading page that displays your desired loading message. Then using ajax (I HIGHLY recommend jQuery) load a separate php file that loads the outside data. Once the data returns to your loading page, it's a simple task of hiding the loading message and replacing it with the output of the ajax.

南街九尾狐 2024-10-02 07:59:34
<?php

     echo "Working...<br/>\r\n"; flush(); //output to the browser before the rest of the execution

     connect_surveygizmo(); //this is going to take while.

     echo "Finished!";

?>
<?php

     echo "Working...<br/>\r\n"; flush(); //output to the browser before the rest of the execution

     connect_surveygizmo(); //this is going to take while.

     echo "Finished!";

?>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文