Skip to content

Instantly share code, notes, and snippets.

@levchik
Last active August 29, 2015 14:04
Show Gist options
  • Save levchik/c7493ec2e213b8852545 to your computer and use it in GitHub Desktop.
Save levchik/c7493ec2e213b8852545 to your computer and use it in GitHub Desktop.
Ajax file submit
$('form').submit(function(){
event.preventDefault();
var fd = new FormData($('.employee-file-form')[0]);
var btn = $(this).find('.js-upload-field-employee');
btn.button('loading');
$.ajax({
url: '/api/v3/upload_field_employees/',
type: 'POST',
data: fd,
cache: false,
contentType: false,
processData: false,
success: function(response){console.log(reponse);},
}).always(function() {
btn.button('reset');
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment