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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:18:25+00:00 2026-05-23T18:18:25+00:00

When i hit savebutton the form is not submitted,what could be wrong with my

  • 0

When i hit savebutton the form is not submitted,what could be wrong with my code?Thank you in advance.I am using Rails 3.1

FORM

 <%=form_for :user ,:remote=>true do |f|%>
 <%= f.label :school %>
 <%= f.text_field :school,:size=>"45",:class=>"round",:id=>"school" %>
 <%= f.submit "save and continue",{:class=>"savebutton" }%>
 <%end%>

JQUERY(application.js)

$(".savebutton").bind('click',function() {  
  $('form').submit(function() { 
    var formToSubmit = $(this).serialize();
    $.ajax({
      url: $(this).attr('action'), 
      data: formToSubmit,
      dataType: "JSON" 
     });
    return false; 
  });
});

CONTROLLER

class SchoolController < ApplicationController
  respond_to :json

  def create
    @school = current_user.schools.build(params[:school].merge(:user => current_user))

    @school = current_user.school.build(params[:school].merge(:user => current_user))

    if @school.save
      respond_with @school
    else
      respond_with @school.errors, :status => :unprocessable_entity
    end
  end
end
  • 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-23T18:18:26+00:00Added an answer on May 23, 2026 at 6:18 pm

    Well @vinceh’s answer is definitely the way you should be doing this, you still can do it the old-fashioned way like you are.

    The .submit() method does not submit the form (you may be thinking it does), but instead binds the form’s submit event to the method you provide. So right now, when you click the submit button, all it does is set up the callback, but then you return false so the form never actually gets submitted.

    You should just be able to get rid of the surrounding $('.savebutton).click(...) handler and put the $('form').submit(...) handler directly in your javascript, so that when the page loads, the callback is registered immediately. You don’t need to worry about handling the .savebutton click specifically.

    Also, your Ajax request probably needs a type: 'POST' or type: 'PUT', since $.ajax defaults to GET requests.

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

Sidebar

Related Questions

I hit a bug in my code which uses WSARecv and WSAGetOverlapped result on
I'm trying to hit a REST api to see if a user is valid.
There is one form i have and a user can click on preview button
I hit this problem in Windows Forms, after using PInvoke of SetWindowLongPtr to remove
I am writing a page where a user can fill out form data, select
I am using paperclip to upload user avatar.Evrery thing work well but when i
I have a form with KeywordInline . When I add new object using the
I have a edit form page and if the user clicks cancel, they go
I hit this error while my web application was trying to execute a SELECT
I hit Linux's 32,000 subdirectory limit. It caused problems with my PHP scripts and

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.