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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:27:49+00:00 2026-05-20T14:27:49+00:00

I am switching a Rails 2.3.8 application from Prototype to jQuery. I am no

  • 0

I am switching a Rails 2.3.8 application from Prototype to jQuery. I am no longer going to use RJS, so that means I am switching my remote_form_for calls to plain old form_for.

However, the submit buttons within these forms are not doing AJAX calls. They are doing regular POSTs.

I have a jQuery function in application.js:

jQuery.fn.submitWithAjax = function () {  
  this.submit(function () {  
    alert("submitting");
    $.post($(this).attr('action'), $(this).serialize(), null, "script");
    return false;  
  });  
};

and I am calling it on my form:

// Search
$('#lookup').submitWithAjax();

Do I instead need to call it on the button itself? I am missing some simple piece here that is preventing all the pieces from falling into place.

  • 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-20T14:27:49+00:00Added an answer on May 20, 2026 at 2:27 pm

    You need to $ around this for this.submit. Also, per the unspoken convention, you should probably wrap that around $.each so you can bind the event to multiple elements.

    $.fn.submitWithAjax = function () {  
        $(this).each(function(){
            $(this).submit(function () {
                $.post($(this).attr('action'), $(this).serialize(), null, "script");
                return false;
              });
        });
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am switching to PostgreSQL from SQLite for a typical Rails application. The problem
I'm switching from a Windows PHP-specific editor to VIM, on the philosophy of use
I am switching from using SQLite3 to PostgreSQL, and hoped that I could populate
We're using Windows 2008 and we are thinking of switching application servers from Adobe
I have built a custom administration panel into a Rails application that allows content
I'm developing an application with Ruby on Rails that I want to maintain for
I'm switching a project from Rails2 to Rails3. I run: rails server The server
I have an application that I am switching to bootstrap. All of the design
After switching to Rails 3, I noticed that I have to reboot my server
I have a Rails application that unfortunately after a request to a controller, has

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.