I am using jquery file upload and it works like a charm. But I got an error when I call send method without any files. I am using the send method which allows me to submit the files asynchronously. On the doc (ctrl-f send) it is said this method returns a jqXHR object that can be used later for callback like fail callback.
When I debug with the chrome debugger I can see that the callback fail is called but all the arguments (jqXHR, textStatus, errorThrown) are undefined. So I get this error in the console : undefined undefined undefined.
I've made this jsfiddle where you can see the bug, just click on the button send by fileupload send api and you'll see the error in the console (open it via F12 before).
Why the arguments are undefined? I think it's a bug...
Here is the javascript :
$(document).ready(function () {
var filesList = []
var elem = $("form")
file_upload = elem.fileupload({
autoUpload: false,
fileInput: $("input:file"),
}).on("fileuploadadd", function (e, data) {
filesList.push(data.files[0])
});
$("button").click(function () {
// fix
if (filesList.length > 0) {
file_upload.fileupload(
'send',
{
files: filesList
}
)
.fail(function (jqXHR, textStatus, errorThrown) {
console.error(jqXHR, textStatus, errorThrown);
})
}
})
});
EDIT : I think I need to check the number of files before trying to upload them. The error function is called but when I inspect the debugger I didn't see any requests to server. So I guess it's a bug, because the fail callback shoudn't be called.