Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7667321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:04:21+00:00 2026-05-31T15:04:21+00:00

I am using jquery ajax call and in controller action i want to redirect

  • 0

I am using jquery ajax call and in controller action i want to redirect some action but when

i use redirect_to “/some_action”. Then it did not redirect to my desired action please give

any useful suggestions.

<%= link_to "javascript:;" ,:onclick => "admin_fun"%>

my jquery ajax call is

function admin_fun() {
  if (confirm("Are you sure you want to add?")) {
    var container = $("#trunk_detail");

    $.ajax({
      url:'/accounting/add_rule',
      type:'get',
      dataType:'html',
      processData:false,
      success:function (data) {
        container.html(data);
      }
    });
  }
}

my controller code is

def add_rule
  # do somthing

  redirect_to "/accounting/index_report"   

  render :text => "ok"
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T15:04:22+00:00Added an answer on May 31, 2026 at 3:04 pm

    This line will not give you the desired results because you can redirect or render multiple times.rather than you omit this line from controller

    redirect_to “/accounting/index_report”

    and in jquery ajax call on success response you can redirect to your desired action like

    if (confirm(“Are you sure you want to add?”)) {

    var container = $("#trunk_detail");
    
    $.ajax({
    
        url:'/accounting/add_rule',
    
        type:'get',
    
        dataType:'html',
    
        processData:false,
    
        success:function (data) {
    
            container.html(data);
    
            window.location.replace("/accounting/index_report"); 
    
        }
    });
    

    }
    }

    And enjoying……..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to call the 'tariff' action of my 'countries' controller using jQuery ajax()
if i call a ajax request using jquery to an asp.net mvc controller action
I am trying to achieve a JQuery AJAX call to a controller action method
How can I call a ViewResult controller action/method from jquery/javascript using something similar to
I want to make delete action asynchronous using AJAX, in the controller I make
How would you access the cache from a jQuery ajax call? I'm using jquery
I am loading feed-items into a ul using this jQuery .ajax() call, which I
I'm using jQuery to make an Ajax call using an Http Post in ASP.NET
I am using jQuery to make an AJAX call to a ruby method in
I'm using JQuery to make an Ajax call. I used a sniffer to catch

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.