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
https://forums.phpfreaks.com/topic/161566-json-is-not-a-function/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.