Skip to content

Instantly share code, notes, and snippets.

@bruth
Created May 22, 2012 20:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bruth/2771363 to your computer and use it in GitHub Desktop.
Save bruth/2771363 to your computer and use it in GitHub Desktop.
require(['jquery'], function($) {
var data,
form = $('#queue-download-form'),
url = queueDownloadForm.attr('action');
form.on('submit', function(event) {
event.preventDefault();
// for JSON
data = JSON.stringify(form.serializeArray());
// for URLEncoded, remove `contentType`
// data = form.serialize();
$.ajax({
url: url,
data: data,
type: 'POST',
contentType: 'application/json',
beforeSend: function(xhr) {
// show a little dialog that it is sending or something
},
success: function(resp) {
// hide the loading dialog
},
error: function(xhr, status, err) {
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment