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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:53:49+00:00 2026-06-17T20:53:49+00:00

Is it possible to add the last record from a database table into the

  • 0

Is it possible to add the last record from a database table into the last row of a html table using jQuery?

Something like this:

  $(".save-expense .btn").click ->
    $('#expense_table').append( Expenses.last )

And indicate which fields to use.

Thanks!

  • 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-06-17T20:53:50+00:00Added an answer on June 17, 2026 at 8:53 pm

    The good news first: Yes it is possible 🙂

    What you want is to send an ajax request to your server which returns with the last expenses information. So your javascript should look something like this.

    application.js

    $(".save-expense .btn").live('click', function(){
      $.ajax({
        type: 'GET',
        url: '/your_controller/last_expense/', # make sure this url is correct
        data: '', # you can also send data if you want
        dataType: "script"
      });
     };
    

    And your controller needs to know how to respond to this request, so:

    your_controller.rb

    def last_expense
      # if you send data you can access it via params hash
      # e.g. params[:my_data]
      @last_expense = Expense.last
      respond_to do |format|
          format.js render 'last_record.js.erb'
      end
    end
    

    the template looks something like:

    _last_record.js.erb

    $('#expense_table').append( <%= j(content) %>)
    # or with a partial
    $('#expense_table').append( <%= j(render partial: 'expense'), locals: @last_expense %>)
    

    PS I’m not sure what you mean with "And indicate which fields to use".
    I’m kind of in a hurry so dont trust the syntax (especially the javascript ;))

    Hope this helps! will check on it tomorrow again, if you need more help.

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

Sidebar

Related Questions

Possible Duplicate: Add table row in jQuery I want to add a new row
Is it possible to add or remove slides in runtime using FlexSlider ?
Is it possible to add a table view on the cells of a table
Is it possible to add messages to the built-in error console of Firefox from
Is it possible add an icon after a link that breaks with the last
In WinForms it was possible to add a new row to the grid by
I would like to add a random value to a table. While I know
Is it possible to add a break tag after every record, but not the
Is it possible to add graphs using the Google Chart API or any other
I want to add the string ,'2') to a row in my database. 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.