This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('form[data-submit=validate]').on('submit', function() { | |
var form = $(this); | |
return form.validate({ | |
error: function(fields) { | |
fields.each(function() { | |
var field = $(this); | |
field.closest('.form-group').addClass('has_error'); | |
field.on('focus', function() { | |
field.closest('.form-group').removeClass('has_error'); | |
field.off('focus'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
var options = { | |
target: '#output', | |
beforeSubmit: beforeSubmit, | |
success: afterSuccess, | |
resetForm: true | |
}; | |
$('#MyUploadForm').submit(function() { | |
$(this).ajaxSubmit(options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var form = $('#contactForm'); | |
form.submit(function(event) { | |
$.ajax({ | |
type: form.attr('method'), | |
url: form.attr('action'), | |
data: form.serialize(), | |
success: function (data) { | |
alert('ok'); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
$(".ajax_request").bind('ajax:before', function(evt, status, data, xhr) { | |
showAjaxLoading(); | |
}); | |
$(".ajax_request").bind('ajax:complete', function(evt, status, data, xhr) { | |
hideAjaxLoading(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var $form = $('#your-form'); | |
$form.on('submit', function(evt){ | |
evt.preventDefault(); | |
$.ajax({ | |
url: $form.attr('action'), | |
type: $form.attr('method'), | |
data: $form.serialize(), | |
success: function(data){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var spinner = $('#ajax-spinner'); | |
$(document).ajaxSend(function() { | |
$('input[type=submit]').attr('disabled', 'disabled'); | |
$('#warningBox').hide(); | |
spinner.show() | |
}).ajaxStop(function() { | |
$('input[type=submit]').removeAttr('disabled'); | |
spinner.hide() | |
}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Canonical ASP.NET MVC usage | |
// site.css | |
.ajax-progress-show, .ajax-progress-error { display: none; } | |
// index.cshtml | |
@Html.Partial("partial",new SampleModel()) | |
// partial.cshtml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('.ajax-forms').submit(onAjaxFormSubmit); | |
var onAjaxFormSubmit = function(evt) { | |
evt.preventDefault(); | |
var $form = $(this); | |
var data = $form.serialize(); | |
var path = $form.attr('action'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('form').submit(e) { | |
e.preventDefault(); | |
$(this).ajaxSubmit({ | |
beforeSubmit: function() { | |
// code to show spinner | |
}, | |
complete: function() { | |
// code to hide spinner | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#file').change(function() { | |
$("#uploader").ajaxForm({iframe: true, success: success}).submit(); | |
}) |