Jump to content

Json is not a function?


lupld

Recommended Posts

Ok, it's submitting a form and it makes it this far, I'll post the entire application.js file to, it's pretty short.

 

Error: $(form_message).removeClass().addClass(json.type).html(json.message).fadeIn is not a function

Source File: http://127.0.0.1/application.js

Line: 29

 

function setupAjaxForm(form_id, form_validations){
var form = '#' + form_id;
var form_message = form + '-message';

// en/disable submit button
var disableSubmit = function(val){
	$(form + ' input[type=submit]').attr('disabled', val);
};

// setup loading message
$(form).ajaxSend(function(){
	$(form_message).removeClass().addClass('loading').html('Loading...').fadeIn();
});

// setup jQuery Plugin 'ajaxForm' 	
var options = {
	dataType:  'json',
	beforeSubmit: function(){
		// run form validations if they exist
		if(typeof form_validations == "function" && !form_validations()) {
			// this will prevent the form from being subitted
			return false;
		}
		disableSubmit(true);
	},
	success: function(json){
		$(form_message).hide();
		$(form_message).removeClass().addClass(json.type).html(json.message).fadeIn('slow');
		disableSubmit(false);
		if(json.type == 'success')
			$(form).clearForm();
	}
};
$(form).ajaxForm(options);
}

 

It displays the "Loading..." and then as soon as there is an error in mozilla it sets the div to display:none;? I really have no idea what's going on, and "is not a function" really gives me no clue where to look.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.