admin管理员组文章数量:1401665
Here is what I've got right now...
I have a web page that when accessed, it connects to surveygizmo 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 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!
Here is what I've got right now...
I have a web page that when accessed, it connects to surveygizmo. 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. 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!
Share Improve this question asked Oct 1, 2010 at 5:03 lewisqiclewisqic 1,9635 gold badges21 silver badges19 bronze badges 1- 1 First thing that es to mind is of course client side insertion of loading image and use AJAX to query the server........... On the server side alone... maybe buffer flushing? – Peter Ajtai Commented Oct 1, 2010 at 5:12
3 Answers
Reset to default 3You'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.
Create a loading page that displays your desired loading message. Then using ajax (I HIGHLY remend 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.
<?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!";
?>
本文标签: javascriptPHP Display a quotloadingquot page while a php script is executingStack Overflow
版权声明:本文标题:javascript - PHP: Display a "loading" page while a php script is executing - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744293661a2599236.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论