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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:14:05+00:00 2026-05-24T18:14:05+00:00

I am retrofitting some code to a Rails 2.3.8 application. The whole app uses

  • 0

I am retrofitting some code to a Rails 2.3.8 application. The whole app uses Prototype, but I need to add some functionality to one controller and its views, so I am switching the old prototype code to jQuery and using a different layout.

So I can’t use link_to_remote in these views any more. I have a situation where I need to “clear out” an attribute for the record in question, in an “edit” action.

I have created a hyperlink with a specific id and bound the click function to it in application.js. I have appended the name of the attribute to the end of this specific id.

So I have two things going into this “remove_attribute” action. I need the id of the record, and the name of the attribute.

I am just serializing the form and submitting. But I need to the add the id of the hyperlinked I clicked!

In my application.js, I have:

hash = { type: "POST", url: "/vehicle_applications/remove", data: $("#myform").serialize() };
$.ajax(hash);
return false;

But you can see that I don’t have the id of the hyperlink in there. I know that to get the id of the hyperlink I refer to:

$(this).attr('id')

But my question is, how do I get a variable name and that value appended on to the results of $(“#myform”).serialize()?

Also, how screwed up is my approach?

  • 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-24T18:14:06+00:00Added an answer on May 24, 2026 at 6:14 pm

    jQuery’s serialize produces a query string:

    The .serialize() method creates a text string in standard URL-encoded notation.
    […]
    a=1&b=2&c=3&d=4&e=5

    So you just need to append another component:

    var data = $('#myform').serialize();
    if(data)
        data += '&id=' + encodeURIComponent($(this).attr('id'));
    else
        data = 'id=' + encodeURIComponent($(this).attr('id'));
    $.ajax({
        url: '/vehicle_applications/remove',
        type: 'post',
        data: data
    });
    

    Depending on your routes, you might want to id in the URL:

    $.ajax({
        url: 'vehicle_applications/remove/' + encodeURIComponent($(this).attr('id')),
        type: 'post',
        data: $('#myform').serialize()
    });
    

    This version should be more typical for Rails and RESTful routing but I don’t know what your routes look like.

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

Sidebar

Related Questions

Retrofitting ASP.NET WebForms themes to an old application I have a need to theme
I have some code that I am retrofitting to use an allocator instead of
Do you have any strategies for retrofitting unit tests onto a code base that
I'm getting started with Boost::Test driven development (in C++), and I'm retrofitting one of
I have been puzzling about retrofitting my app for iCloud for a few days
I'm retro-fitting an older vb.net application to bring it into compliance with LUA principles
In a Windows Phone 7 app, the PhoneApplicationService.Current.State object is declared as an IDictionary,
As my previous posts can attest, I'm retrofitting in-memory, network-cached performance to what was
I need your recommendations for continuous build products for a large (1-2MLOC) software development
My team is writing a content-managed web-hosting application in ASP.Net MVC 2 with 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.