简体   繁体   English

显示AJAX当前请求的状态

[英]Showing status of current request by AJAX

I'm trying to develop an application which modifies a couple of tasks of the famous Online-TODO List RememberTheMilk (rememberthemilk.com) using the REST API. 我正在尝试开发一个应用程序,该应用程序使用REST API修改著名的Online-TODO List RememberTheMilk(rememberthemilk.com)的几个任务。

Unfortunately the modifying takes a lot of time, so I want to give a feedback to the users. 不幸的是,修改需要花费很多时间,因此我想向用户提供反馈。 My idea was just to display a couple of text lines (eg modifying task 1 of n...). 我的想法只是显示几个文本行(例如,修改任务1的n ...)。 Therefore I used the periodically_call_remote on my page and called a which reads a Singleton. 因此,我在页面上使用了periodic_call_remote,并调用了一个读取单例的a。

In the request I store the text that should be displayed in the same singleton. 在请求中,我存储应在同一单例中显示的文本。 But I found out, that once I set up a request, the periodically_call_remote does not update the specified div. 但是我发现,一旦我建立了一个请求,periodic_call_remote就不会更新指定的div。

My question to this: 1. is this a good way to implement this behaviour? 我对此提出的问题:1.这是实施此行为的好方法吗? 2. if it is, how do get the periodically_call_remote to work during a submit? 2.如果是,如何在提交期间使periodicate_call_remote工作?

Using a Singleton is most definitely a bad idea. 使用Singleton绝对是一个坏主意。 In an advanced production setup it isn't guaranteed that subsequent requests will go to the same process or to the same machine (and subsequently will have a different Singleton). 在高级生产设置中,不能保证后续请求将发送到同一流程或同一台机器(随后将具有不同的Singleton)。 Plus, if you have many users, I don't even want to think about what'll happen to those poor Singletons. 另外,如果您有许多用户,我什至不想考虑那些可怜的Singletons将会发生什么。

Does any of this stuff actually need to go through your Rails app? 这些东西中是否真的需要通过您的Rails应用程序? It seems like you can call the RTM API via Javascript from the page the user is on and then update the page when the XHR request is complete. 看来您可以从用户所在的页面通过Javascript调用RTM API,然后在XHR请求完成时更新页面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM