cakephp:在执行进程/函数时将输出发送到浏览器 [英] cakephp: send output to browser while executing a process/function

查看:133
本文介绍了cakephp:在执行进程/函数时将输出发送到浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在cakephp中建立进度列?

How can i make a progress bar in cakephp?

和其他相关问题是

说,对于一个循环,我如何发送输出到浏览器的每一次迭代.....在cakephp ....
我试过使用setflash函数,但did not为我工作....

lets say, for a loop, how can I send output to the browser for every iteration..... in cakephp.... I tried using setflash function, but didnt worked for me....

我的主要意图是尝试上面的事情,是我想要发送一些输出到浏览器几秒钟,而我的功能正在执行,否则我进入timout的问题。 ....

My main intention in trying above things, is that I want to send some output to browser for every few seconds while my function is getting executed, else I go into the problem of timout.....

感谢...

推荐答案

真的这样做。返回的网页是静态的,您不能在发送它时更改它。在纯PHP中,你可以在所有输出之前发送部分输出,所以你可以有 for($ i = 0 ;;)echo $ i ++; 你不能在Cake中做到这一点,因为你需要在将视图完全插入布局之前渲染它。
进度条是(纯)HTML不可能的,因为正如所说,你不能修改发送的HTML响应。

You can't really do that. A returned web page is something static, you can't change it when you sent it. In pure PHP you could send portions of the output before you have all the output, so you can have something like for($i=0;;) echo $i++; but you can't do this in Cake because you need to render a View completely before inserting it into the layout. A progress bar is in (pure) HTML impossible, because as said, you can't modify a sent HTML response.

但是,进入play:你可以返回一个HTML页面与JS,使用AJAX调用查询一个动作的状态/百分比,然后它分别设置进度条在HTML。它可以做后者(修改HTML),因为JS在页面检索后在客户端的浏览器中运行。

However, you can bring JavaScript into play: You can return a HTML page with the JS, that uses AJAX calls to query the state/percentage of an action, and then it sets the progress bar in the HTML respectively. It can do the latter (modify HTML) because JS runs in the clients' browser after page retrieval.

这篇关于cakephp:在执行进程/函数时将输出发送到浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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