I have a form that throws 500 error with the following lines on the trace
send @ jquery.js:9536
ajax @ jquery.js:9143
(anonymous) @ practice:177
dispatch @ jquery.js:5201
elemData.handle @ jquery.js:5009
Form is
<form id = 'sendForm' enctype='multipart/form-data'>
<div class="form-group">
<input type = 'text' style = 'display: none;' name = 'idExer' id = 'idExer'>
<label class="control-label">Sube tu archivo de Python para probar el código
</label>
<input type="file" name="solution" id="solution">
</div>
<input type="submit" class="btn common-btn ">Enviar código</input>
</form>
And ajax call is
$('#sendForm').submit(function(e){
var form = document.querySelector('#sendForm');
var formData = new FormData(form);
e.preventDefault();
$.ajax({
crossOrigin: true,
type:'POST',
url: '/student/practice/'+ $("#idExer").val(),
data: formData,
processData:false,
contentType:false,
success: function (data) {
},
error: function(response) {
console.log(response.status + " " + response.statusText);
}
});
});
The router is like
router.post('/practice/:id', function(req, res, next){
//stuff here
}
This is on an Express app and the form is on the same route as the post one. The form has one file upload and a hidden input that passes as a parameter on the ajax call.