Skip to content

Instantly share code, notes, and snippets.

@jamalnasir
Created March 8, 2017 13:30
Show Gist options
  • Save jamalnasir/29443d771abe40eea184cb5d1eb7c338 to your computer and use it in GitHub Desktop.
Save jamalnasir/29443d771abe40eea184cb5d1eb7c338 to your computer and use it in GitHub Desktop.
Upload file with ajax
$("body").on("submit", "#my-form", function(e){
e.preventDefault();
var _this = $(this);
var formData = new FormData(this);
$.ajax({
url: 'some-url',
data: formData,
method: 'POST',
cache:false,
contentType: false,
processData: false,
beforeSend: function(){},
success: function(response){},
error: function(error){},
complete: function(){}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment