Welcome to Working With Rails


Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
Showing status of current request by AJAX
2 Posts
Showing status of current request by AJAX

Hi everyone, 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.

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 (e.g. modifying task 1 of n...).

Therefore I used the periodically_call_remote on my page and called a which reads a Singleton. 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.

My question to this: 1. is this a good way to implement this behaviour? 2. if it is, how do get the periodically_call_remote to work during a submit?

regards leifg

You may want to consider processing the task asynchronously, if you aren't doing this already. DelayedJob is an excellent way to do this: http://tobi.github.com/delayed_job/

As for reporting on status, you could do this by polling asynchronously. Make sure that the entire page loads each time the user navigates before starting the polling task. Alternatively, you could try these alternatives: * Send email when the task is done. * Check the status of the request on each page render, and report the status in a flash message. * Display an alert message in the browser when the task is done instead of updating the page directly.

2 Posts
Login to add your message