If you open a preloader and then close immediately, it then cannot be closed.
https://jsfiddle.net/qdechochen/80nf31wr/
Here I open a preloader before an ajax request, and after get the data, close it. This cause problem when the request is very fast. Right now I have to do a setTimeout before close the preloader.