PHP:显示“正在加载” php脚本正在执行时的页面 [英] PHP: Display a "loading" page while a php script is executing

查看:542
本文介绍了PHP:显示“正在加载” php脚本正在执行时的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我现在所拥有的...

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

我有一个网页,当访问它时,它通过他们的开放API连接到surveygizmo.com,检索大量数据,然后将这些数据返回给我,以便在我的最后处理。这个过程大约需要10-12秒,当它正在执行时,页面处于加载状态,我显示一个空白页面。

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

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

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.

我对php和javascript非常熟悉,但还未能解决这个问题。任何有关此事的指示或建议都将不胜感激。

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.

谢谢!

推荐答案

你想看看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.

这篇关于PHP:显示“正在加载” php脚本正在执行时的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆