drtwqc3744 2016-07-27 15:16
浏览 105

如何通过jQuery(ajax)跟踪提交给服务器的请求的进度?

I have some PHP app. At the moment I am developing part where an user submits a request/form to the server via ajax (jQuery). Server will insert thousands of records in MySQL database that will probably take couple minutes (due to various calculations etc).

Question: Is there a way to track progress of updates on server side? I understand I can write some output once everything is finished. A workaround would be something like: - store somewhere session ID plus progress details (example: processed 3k inserts out of 5k - maybe in some progress table in database - have front end jQuery script requesting that information from the server every 10 seconds or so...

Any ideas? Please feel free to ask any question you may have. Thank you.

  • 写回答

1条回答

  • dousendun8411 2016-07-27 15:28
    关注

    While I don't know the specifics of what you're doing server-side, a script that takes a "couple minutes" to execute likely involves several distinct steps. It might make sense to have the script execute one step at a time, return its result, and then get called again to execute the next step.

    By using a process like this, you'll be able to track progress client-side. The caveat is that if the client closes the browser window or leaves the page with your ajax code, the remaining steps won't be executed.

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器