jQuery(document).ready(function($) { $('form.ajax').on( 'submit', function() { var el = $(this); $('.ajaxresponse', el).addClass('loading ajaxloading').hide().html('Processing ...').fadeIn('slow'); $.post(mega.ajax, el.serialize(), function(response) { $('.ajaxresponse', el).removeClass('loading ajaxloading').html(response).show(); } ); return false; } ); });