Wednesday, February 2, 2011

How to make a remote call synchronous in Rails

new Ajax.Request('/controller/action?username=praveen', {asynchronous:false, evalScripts:true, parameters:'page_offset=' + page_offset + '&authenticity_token=' + encodeURIComponent('e060znd6JcrMCU6Bf4ZZnfyBac4tl1YXQ6HuEHZGY58=')});

What to do to get that "asynchronous:false" thing in your link_to_remote or any other helper function available in rails :)

I know its not a big thing and there is/are very few requirements to make an Ajax call synchronous but one might face this requirement sometimes, and the answers is
<%=remote_function(:url => {:controller => "controller", :action => "action", :username => "praveen"}, :type => :synchronous, :with => "'page_offset=' + page_offset") -%>

And you are done... so now till the time this thing is taking place, everything in browser will be waiting to complete the process first and then only proceed next.
Hope you stumble on me looking in for me.

3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. I am looking for and I love to post a comment that "The content of your post is awesome" Great work! remote device management

    ReplyDelete
  3. Great survey, I'm sure you're getting a great response. Angel broking customer care

    ReplyDelete

Honda Civic & A/C problems.

Hello Friends, Got a post again on to Honda Civic (The good old favorite commuter of mine). This car has been doing great except for so...