Rails 3: How to “redirect_to” in Ajax call?


Replaced below redirect method

redirect_to(:controller => 'jobs', :action => 'index')

with this:

render :js => "window.location = '/jobs/index'"

and it works fine!

Else

Pass static url to link

= link_to ‘Set as application form’, “org_form_and_documents?id=#{params[:id]}”, :onclick => “set_as_app()”, :class => “active”

function set_as_app()
  {
      var IDs = [];
      $(“.form_check”).each(function()
      {
        var each_id = ‘#’+this.id;        
        if ($(each_id).attr(‘checked’))
        {            
            IDs.push(this.id);
            $.ajax({
                 url: “/organizations/change_form”,
                 data: { form_id: this.id, org_id: $(‘#org’).val(), season: $(‘#season’).val()},
                 cache: false,                      
            })
        }                  
      });
      
  }
I hope, it will help..!!!

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s