使用AJAX,页面如何从backgroud PHP脚本获取状态信息? [英] Using AJAX, how can the page get state infomation from backgroud PHP script?

查看:40
本文介绍了使用AJAX,页面如何从backgroud PHP脚本获取状态信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我不熟悉网页编程,但我在这里遇到了问题。


我有一个页面。当用户单击其上的一个按钮时,我将使用AJAX来请求一个PHP脚本,该脚本将异步执行一系列任务。

这些任务可能需要很长时间所以我想让用户了解

的进展情况。问题是只有PHP脚本知道

进度,网页如何从PHP脚本中获取这些信息?


我真的很感激如果有人可以帮我解决这个问题。

Hi,

I''m not familiar with web programming, but I have a problem here.

I have a page. When a user click one button on it, I will use AJAX to
request a PHP script which will do a bunch of tasks, asynchronously.
These tasks might take long time so I want to keep the user informed
of the progress. The problem is that only the PHP script knows the
progress, how can the web page gets these information from PHP script?

I''d really appreciated if someone could help me solve this problem.

推荐答案

Marvin Zhang写道:
Marvin Zhang wrote:




我不熟悉网络编程,但我在这里遇到了问题。


我有一个页。当用户单击其上的一个按钮时,我将使用AJAX来请求一个PHP脚本,该脚本将异步执行一系列任务。

这些任务可能需要很长时间所以我想让用户了解

的进展情况。问题是只有PHP脚本知道

进度,网页如何从PHP脚本中获取这些信息?


我真的很感激如果有人可以帮我解决这个问题。
Hi,

I''m not familiar with web programming, but I have a problem here.

I have a page. When a user click one button on it, I will use AJAX to
request a PHP script which will do a bunch of tasks, asynchronously.
These tasks might take long time so I want to keep the user informed
of the progress. The problem is that only the PHP script knows the
progress, how can the web page gets these information from PHP script?

I''d really appreciated if someone could help me solve this problem.



只是一个想法,一个做过它的人可能会更清楚。


- 让你的原始PHP存储它的状态会话中的信息

变量说

Just an idea, someone who''s done it may know better.

- Have your original PHP store it''s "status" information in a Session
variable says


_SESSION [" status_data"]这是运行时的更新


- 在Javascript端有一个计时器,它创建第二个Ajax调用

到一个新的getstatus.php,然后从会话中读取状态并且

发回给这个第二次Ajax调用中的浏览器。


没做太多的Ajax,我假设你可以再做一个ajax调用,而

当前正在运行吗?


你可能需要在你的b $ b调用getstatus.php时将PHP会话ID发送回服务器,不确定。


我们不管你怎么做:)
_SESSION["status_data"] which is updates as it runs

- Have a timer on the Javascript side which creates a 2nd Ajax call
to a new getstatus.php, which then reads the status from the session and
sends back to the browser in this 2nd Ajax call.

Not done much Ajax, I am assuming you can make another ajax call whilst
one is currently running??

You might need to send the PHP session id back to the server when you
call getstatus.php, not sure.

Let us no how you do :)



- 让你原来的PHP存储它''状态"会话中的信息

变量说
- Have your original PHP store it''s "status" information in a Session
variable says


这篇关于使用AJAX,页面如何从backgroud PHP脚本获取状态信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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