$(this).ajaxSubmit is not a function

user1082534 picture user1082534 · Jan 8, 2012 · Viewed 14.6k times · Source

I am using rails 3.1.3, and jquery.form.js version 2.9.4, and jquery 1.7.1. I put some console print statements in jquery.form.js, so I can see (in the firebug console) that it has loaded.

And I set up my form like this:

var options = {
  success: s.update_or_add_contact_response, type: 'post', 
  dataType: 'json',  url:  s.update_contact_path
};

$('form#new_user').submit(function() {
  $(this).ajaxSubmit(options);
  return false;
});

And when I click on a button to submit the form I get the following error message in the firebug console:

$(this).ajaxSubmit is not a function

What am I doing wrong here?

Answer

Shiv Aggarwal picture Shiv Aggarwal · Feb 5, 2014

This is new function so you have to add other lib file after jQuery lib

<script src="http://malsup.github.com/jquery.form.js"></script>

it will work.. I have tested.. hope it will work for you..