Last active
September 30, 2016 17:27
-
-
Save devmeireles/d343d9f5860a0598267596dcf0a7b81b to your computer and use it in GitHub Desktop.
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
$(document).ready(function(){ | |
$("#submitBtn").click(function(){ | |
form = $(".formSend"); | |
var data = new FormData(); | |
var file_data = $('input[type="file"]')[0].files; // for multiple files | |
for(var i = 0;i<file_data.length;i++){ | |
data.append("file_"+i, file_data[i]); | |
} | |
var other_data = $(form).serializeArray(); | |
$.each(other_data,function(key,input){ | |
data.append(input.name,input.value); | |
}); | |
$.ajax( { | |
type: "POST", | |
url: form.attr('action'), | |
//data: form.serialize(), | |
data: data, | |
enctype: 'multipart/form-data', | |
processData: false, | |
contentType: false, | |
dataTYpe: 'json', | |
success: function( response ) { | |
console.log(response); | |
console.log(response.success); | |
//$('#modalReturn').modal('show'); | |
} | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment