Created
April 5, 2019 13:34
-
-
Save rickslayer/9841371988c640240746096658c64141 to your computer and use it in GitHub Desktop.
Send parameteres and Files together Ajax - Enviar parametros e arquivos juntos em requisição
This file contains 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
<html> | |
<input type="file" id="files"> | |
</html> | |
<script> | |
$(function(){ | |
$("#files").on('change', function(event) | |
{ | |
form = new FormData(); | |
form.append('files', event.target.files[0]); | |
form.append('anotherparam', "teste"); | |
let callBack = $.ajax({ | |
url: 'ajaxcallurl', | |
data: form, | |
processData: false, | |
contentType: false, | |
type: 'POST', | |
success: function (data) { | |
console.log(data); | |
} | |
}); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment