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() { | |
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
$('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
$('#form').submit(function() { | |
payload = $(this).serialize(); | |
$.ajax({ | |
url: 'http://', | |
type: 'POST', | |
data: payload, | |
dataType: 'jsonp' | |
success: function(data){ | |
// present success message here | |
} |
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
/* | |
* jQuery.ajaxEnvironment.js | |
* https://gist.github.com/jhogervorst/8166217 | |
* | |
* jQuery.Mobile.ajaxUpload.js | |
* https://gist.github.com/jhogervorst/8166385 | |
* | |
* Copyright (C) 2013 Jonathan Hogervorst. All rights reserved. | |
* This code is licensed under MIT license. | |
*/ |
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
(function($){ | |
$(function(){ | |
var $form = $('#search'), // Search form | |
$target = $('#results'), // Results container | |
rp = 'search/ajax-results'; // Template for results only | |
// Function to execute on success | |
var success = function(data, status, xhr) { | |
$target.html(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
$("#contact_form").validate({ | |
submitHandler: function(form) { | |
$.ajax({ | |
type: "POST", | |
url: "util/misc_func.php", | |
data: { | |
action: "validate_domain", | |
email: $("#form_email").val() | |
}, |
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
function AjaxForm($el) { | |
this.$form = $el; | |
this.form = $el[0]; // Internal state via properties | |
this.$form.on('submit', $.proxy(this.submit, this)); | |
}; | |
AjaxForm.prototype = { | |
submit: function(e) { // Named Functions | |
e.PreventDefault(); | |
var this = this; |
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
// Fire ajax when some button is clicked | |
$('#button').click(function() { | |
$.ajax({ | |
type: 'POST', | |
url: '/controller/method/', | |
beforeSend: function() { | |
}, | |
success: function(response) { |
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
function progressHandler(event){ | |
$("#kb_of_total").text("Uploaded "+Math.round(event.loaded/1024) +" kb of "+Math.round(event.total/1024)); | |
var percent = (event.loaded / event.total) * 100; | |
$("#progressBar").attr('value', Math.round(percent)); | |
$("#status").text(Math.round(percent)+"% uploaded... please wait"); | |
} | |
function completeHandler(event){ | |
$("#progressBar").attr('value', 100); | |
$("#status").text('Uploaded Success'); | |
successHandler(event); |