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

  • Home
  • SEARCH
  • 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

We're considering switching our site from Prototype to jQuery. Being all-too-familiar with Prototype, I'm
I am going to switching SSL onto a Rails site of mine pretty soon
When dropping the use of rspec and rspec-rails plugins and switching to the gem
I'm developing an application with Ruby on Rails that I want to maintain for
We're using Windows 2008 and we are thinking of switching application servers from Adobe
I have a Rails application that unfortunately after a request to a controller, has
We're thinking about switching technology for our future projects going from C++ to Java
Ever since switching from TABLE-layout to DIV-layout, one common problem remains: PROBLEM : you
We are considering switching from MS Visual Studio 2003 to MS Visual Studio 2005
I've found this a somewhat dated tutorial for developing a Rails application on Leopard

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.