$(function () {
    $('form').submit(function (e) {
        e.preventDefault();
        $('#ajaxSuccess').hide();
        if ($('form').valid()) {
            var $loader = $('#ajaxLoader')
            var $submit = $('input[type=submit]');
            $.ajax({
                url: this.action,
                type: this.method,
                data: $(this).serialize(),
                success: function (result) {
                    if (!result.Success) {
                        $('#formcontent').html(result);
                        //$.validator.unobtrusive.parse('#formcontent');
                    }
                    else {
                        $('#ajaxSuccess').show();
                    }
                    $loader.hide();
                    $submit.removeAttr('disabled');
                },
                beforeSend: function (data) {
                    $loader.show();
                    $submit.attr('disabled', 'true');
                }
            });
        }
    });
});
