Simple way to post form data to component using AJAX


$.fn.serializeObject = function()
{
	var o = {};
	var a = this.serializeArray();
	$.each(a, function() {
		if (o[this.name] !== undefined) {
			if (!o[this.name].push) {
				o[this.name] = [o[this.name]];
			}
			o[this.name].push(this.value || '');
		} else {
			o[this.name] = this.value || '';
		}
	});
	return o;
};

$(function() {
	$('form').submit(function() {
	
	var request = {
		'option'	:	'com_meta',
		'view'		:	'apis',
		'cmd'		:	'<?php echo $command; ?>',
		'format'	:	'raw',
		'data'		:	JSON.stringify($('#form').serializeObject())
	};
	
	$.ajax({
		type: 'POST',
		data: request,
		success: function(resp) {
			console.log(resp);
		},
		error: function() {
			console.log('error');
		}
	});
	
	return false;
	
	});
});