This file contains hidden or 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('.ajax-form'); | |
}) | |
var ajaxForm = function(query) | |
{ | |
$(query).submit(function(event) { | |
event.preventDefault(); | |
var $form = $(this); |
This file contains hidden or 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
// Array Iteration: | |
myArray = [ 'foo' ]; | |
myArray.forEach(function(x) { console.log(x); }); | |
// prints "foo" | |
// Object Keys: | |
myObject = { foo: 'bar', baz: 'quux' }; | |
Object.keys(myObject); // [ "foo", "baz" ] | |
// Object Iteration Helper (context is optional) |
This file contains hidden or 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 buildSubmitHandler(ajaxOptions) { | |
function submitViaAJAX(event) { | |
var data = $.extend( {}, ajaxOptions.data, $form.serialize() ), | |
options = $.extend({}, { | |
url: $form.attr('action'), | |
type: $form.attr('method'), | |
}, ajaxOptions, { data: data }); | |
$.ajax(options) |
NewerOlder