How to execute an ajax callback after completing a Hold job in Ruby on Rails?

I allow users on my site to rotate their photos. I accomplish this by ajax calling the Delayed_Job process (via Heroku) that rotates the photo. After they click "rotate photo", I show the bootloader. But my question is this: what is the best way for my page to know when Delayed_Job is completed so that I can upload a new photo?

Do I need to have a continuous ajax polling of my server to determine if the Delay job has completed? Or can I somehow implement the ajax callback on my page that will notify my page of the completion of the Delayed Job?

Thanks in advance.

+3
source share
1 answer

There are tons of ways to deal with such things. You could do an ajax poll, as you mentioned, you can use the comet method , where you practically leave the connection open until the server is turned on, or you can even use web sockets with all your might (maybe this is a bit overkill for this task).

Without sockets, there is currently no way to send a server message to a client without a client request.

, , , //. . , , ( delayed_job). , ajax , , .

+5

Source: https://habr.com/ru/post/1785346/


All Articles