What is the right way to make a new XMLHttpRequest from an RJS response in Ruby on Rails?
Posted
by Yuri Baranov
on Stack Overflow
See other posts from Stack Overflow
or by Yuri Baranov
Published on 2010-04-01T13:38:59Z
Indexed on
2010/04/01
13:43 UTC
Read the original article
Hit count: 402
I'm trying to come closer to a solution for the problem of my previous question.
The scheme I would like to try is following:
- User requests an action from RoR controller.
- Action makes some database queries, makes some calculations, sets some session variable(s) and returns some RJS code as the response. This code could either
- update a progress bar and make another ajax request.
- display the final result (e.g. a chart grahic) if all the processing is finished
- The browser evaluates the javascript representation of the RJS. It may make another (recursive? Is recursion allowed at all?) request, or just display the result for the user.
So, my question this time is: how can I embed a XMLHttpRequest call into rjs code properly?
Some things I'd like to know are:
Should I create a new thread to avoid stack overflow. What rails helpers (if any) should I use?
Have anybody ever done something similar before on Rails or with other frameworks?
Is my idea sane?
© Stack Overflow or respective owner