Skip to content

Instantly share code, notes, and snippets.

@MattTheRed
Created June 4, 2013 20:19
Show Gist options
  • Save MattTheRed/5709203 to your computer and use it in GitHub Desktop.
Save MattTheRed/5709203 to your computer and use it in GitHub Desktop.
$('input[type="file"]').each(function() {
var $file = $(this), $form = $file.closest('.upload-form');
$file.ajaxSubmitInput({
url: '/', //URL where you want to post the form
beforeSubmit: function($input) {
//manipulate the form before posting
},
onComplete: function($input, iframeContent, options) {
if (iframeContent) {
$input.closest('form')[0].reset();
if (!iframeContent) {
return;
}
var iframeJSON;
try {
iframeJSON = $.parseJSON(iframeContent);
//use the response data
} catch(err) {
console.log(err)
}
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment