I filled up an array with a lot of information(80+variables) and 1 file.
var ArrayEnv= {LOTS OF VARIABLES DECLARED + 1 File}
console.log(ArrayEnv); -> Just for testing purposes
$.ajax({
url: 'controller/send_data',
data: ArrayEnv,
type: 'POST',
cache: false,
contentType: false,
processData: false,
before: '',
success: function(data) {
console.log('Ajax Value: '+data);
}});
So, when I send the data to the controller without the FILE, everythin goes right, but whenever I send a file it crashes. I dont want to use formData since im getting and validating multiple variables through branchings on the JS.
I've done a lot of research and im really losing hope... is there any way to send a file in the same array that containts the data?
Actually had to use formData to make it work
data = new FormData($("#validatedForm")[0]);
$.ajax({
url: 'controller/send_data',
data: data,
cache: false,
contentType: false,
processData: false,
beforeSend: function() {
console.log('Load');
},
method: 'POST',
// type: 'POST', // For jQuery < 1.9
success: function ( data ) {
console.log( data );
}
});