如何使进度条与jQuery和PHP在等待服务器进程? [英] How to make progress bar with jQuery and PHP while waiting server process?

查看:173
本文介绍了如何使进度条与jQuery和PHP在等待服务器进程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它曾经是很容易找到我的问题的解决方案时,谷歌提供指向许多#1准确的结果。但是,我并没有找到一个针对此问题。如果你们有意见,我应该去这个问题,请给我链接到了答案。

目前,此案我想从数据库使搜索索引。在索引过程 jQuery.getJSON 触发。它需要时间才能完成这样的我想使进度条来显示索引过程。我知道如何使用 .getJSON 作为客户端和PHP作为服务器端,使常见的Ajax请求,但看来我很难想象如何让这样的进度条。

有没有任何机构可以向我解释如何做到这一点?

解决方案
  1. 检查jQuery的进度条界面: http://jqueryui.com/progressbar/ <​​/A>
  2. 使用.getJSON或AJAX调用每隔10秒调用服务器并检查进度
  3. 后,你的服务器进程更新UI

解释步骤2

第二步通常是基于应用程序的流量,可以说,例如我在MYSQL中插入10万条记录,我将创造另一项服务,将检查的行数,结果是30000条记录,例如,这意味着进展现在是30%,所以,如果我把这个服务每10秒我将获得当前的进展情况。

It used to be easy to find solutions of my problem when Google gives many accurate results that point to Stackoverflow. But, I didn't found one for this problem. If any of you have suggestion where should I go for this problem, please give me link to the answer.

The case is I want to make searching index from database. The indexing process is triggered by jQuery.getJSON. It takes minutes to finish so I want to make progress bar to show that indexing process. I know how to make common ajax request using .getJSON as client side and PHP as server side, but It seems difficult for me to imagine how to make such progress bar.

Is there any body that can explain to me how to do that?

解决方案

  1. check Jquery Progress bar UI : http://jqueryui.com/progressbar/
  2. use .getJSON or an ajax call every 10 seconds to call the server and check the progress
  3. after you get the server progress update the UI

Explaining Step2

step 2 is generally based on your application flow, lets say for example i'm inserting 100,000 records in MYSQL, i would create another service that will check the rows count and the result were 30,000 records for example, that means the progress now is 30%, so if i call this service every 10 seconds i would get the current progress.

这篇关于如何使进度条与jQuery和PHP在等待服务器进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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