Reputation: 81
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?
Upvotes: 2
Views: 16069
Reputation: 420
I think jQuery must be conflicting with other js files, you can find some help from here, replacing $
by jQuery
in the code might help.
Upvotes: 0
Reputation: 499
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..
Upvotes: 6
Reputation: 2967
I have never used this function, but your syntax looks correct according to the doc at: http://jquery.malsup.com/form/#ajaxSubmit.
Without seeing all of your code I would guess either you aren't linking the jQuery plugin, or you aren't wrapping your code in $( document ).ready( function( ) { //code } );
as such.
Look at your source code and make sure that the plugin is being linked. Is it there?
Put in an alert just above var options
. Does it output?
Upvotes: 2
Reputation: 13198
Maybe you're missing the document.ready wrapper?
$(function() { // same as document.ready
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;
});
});
Upvotes: 0