I have a common input file. Pressing opens the corresponding window to choose a file from your computer.
I have a function that loads a gif of "loading" when you click on the input button; and when selecting the image and processing the sending of the image by ajax to the server this gif is hidden.
But how do I hide the gif if the user gives "cancel" or closes the window without choosing a file?
The gif is hidden when selecting and processing an input file because the onchange event is launched.
How can I do it?
<input type="file" id="file"/>
JS:
$("#file").on("click", function(){
$(".gif").show();
});
$("#file").on("change", function(){
$.ajax({
...,
complete(){
$(".gif").hide();
}
});
});