[英]Python with CGI - handle ajax
I'd like to: 我想:
How can I do that? 我怎样才能做到这一点?
You could do this - 你可以这样做 -
But having a server is the way to go... Maybe the long running process stores the progress in a MySQL table. 但拥有服务器是可行的方法......也许长时间运行的进程将进度存储在MySQL表中。
Hope this helps... 希望这可以帮助...
On the server side, you should probably look into some background queue / job runner of sorts, otherwise your request will be blocked once the long operation starts (depends on your server). 在服务器端,您可能应该查看一些后台队列/作业运行器,否则一旦长时间操作开始(取决于您的服务器),您的请求将被阻止。 I hear Celery is pretty good.
我听说芹菜很不错。 On the client side, do some polling every x seconds that checks the job status.
在客户端,每隔x秒进行一次轮询以检查作业状态。 If you're feeling adventurous, you could experiment with websockets, although they're not supported natively in all browsers (you could use 3rd party extensions to try and accomplish cross browser support).
如果你喜欢冒险的感觉,你可以使用WebSockets实验,虽然他们没有在所有浏览器(可以使用第三方扩展,试图实现跨浏览器支持), 原生支持。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.