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 6128019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:34:45+00:00 2026-05-23T16:34:45+00:00

I want to create an AJAX call on an action, let’s call it seen,

  • 0

I want to create an AJAX call on an action, let’s call it seen, so that a field in my database gets updated on a click. This is a follow-up question to a previous response I got yesterday, so bear with me because I am rather inexperienced.

<%= button_to "Click me!", :action => "some_action", :remote => true %>
Which will send an AJAX request back to the server, in which you need to handle in your controller

def some_actoin
    // Update your database here
    respond_to do |format|
        format.js { render 'somepartial' }
    end
end

Does this answer essentially mean that I need to create a route associated with the def some_action? If so what format should this route take.

I don’t want the user to navigate away from the page, I just simply want to update one div on the current page.

  • 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-23T16:34:45+00:00Added an answer on May 23, 2026 at 4:34 pm

    You’ve got a good start. When that button is clicked rails/the server will send an HTTP request to that controller/some_action. It will hit that action method where you need to save to the database. From there it will respond with javascript (hence the format.js). The javascript file it is responding with (assuming you are using jquery and not prototype) will be called some_action.js.erb . Within that file you put all of your jquery function calls etc that you want to occur once that ajax request has returned.

    EDIT:

    To further clarify with the routes. You need to be able to access controller/some_action as normal. This means that there needs to be a route defined:

    match 'controller/some_action' => "controller#some_action"
    

    however you don’t need to do anything extra to tell rails its a remote route.

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

Sidebar

Related Questions

I want to create some kind of AJAX script or call that continuously will
I want to create a simple AJAX call, based on How to use Servlets
I want to create a jQuery dialog from HTML returned by an AJAX call.
I want to create a stored procedure (on SQL Server 2005) that fetches a
when I create a area I use JQuery to call the action create the
I'm trying to call ajax inside beforenodedrop event, and when success, I want to
I am Submiting form through MOUSE CLICK and ENTER too. Ajax Call is checking
For a click tracking feature I need to create a hidden page that reads
Before my form initiates an AJAX request, I want to call a function. I
I have a controller with a create action and I want to render the

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.