开发者

Ajax asynchronous in ruby helpers

I'd like to know how to run an asynchronous ajax request through a ruby on rails helper. To be more specific, I need to开发者_运维百科 call remote_function:

remote_function  :url => { :action => "draw_graph" }, :after => "do_something_after_ajax_is_done()" }

But do_something_after_ajax_is_done() is executing while ajax request is running and it mess up my plans.

I thought of using :async => false or :asynchronous => false option but it does not seem to work. Could you help me on the syntax or tell me what is wrong with my way of doing it.

Is remote_function even taking option for asynchronous option?


I think you want :complete

  remote_function  :url => { :action => "draw_graph" }, :complete => "do_something_after_ajax_is_done();"

this will run when the Ajax request has returned. If you only want to run if it's successful, use :success

  remote_function  :url => { :action => "draw_graph" }, :success => "do_something_after_ajax_is_done();"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜