Javascript ajaxStart在没有“启动”的情况下无法正常运行;“警惕”;

Javascript ajaxStart在没有“启动”的情况下无法正常运行;“警惕”;,javascript,jquery,ajax,Javascript,Jquery,Ajax,下面是我的代码,用于在ajax仍在运行时尝试放置加载程序。我的问题是,如果我发出警报,我就会得到我需要的东西。但如果我删除警报,它不会显示“正在加载…”。 Javascript: $(document).ajaxStart(function() { $('#loading').html("Loading..."); console.log("hii"); alert("gg"); }); HTML: 当请求结束时,您是否隐藏它?也许请求太快了,你看不到它,而你只看到警报,

下面是我的代码,用于在ajax仍在运行时尝试放置加载程序。我的问题是,如果我发出警报,我就会得到我需要的东西。但如果我删除警报,它不会显示“正在加载…”。 Javascript:

 $(document).ajaxStart(function() {
   $('#loading').html("Loading...");
   console.log("hii");
   alert("gg");
 });
HTML:


当请求结束时,您是否隐藏它?也许请求太快了,你看不到它,而你只看到警报,因为它会暂停执行。真的吗?我的请求实际上太慢了,我需要显示一个加载器…我也尝试过这样做,但没有显示任何不同的结果。但你似乎有一个正确的观点。我的页面在没有警报的情况下冻结,我必须等待ajax请求结束您的ajax请求,这是一个同步请求(Jax;)
<div id="loading"></div>
$.ajax({
    url: xyz,
    data: dataObj,
    type: request_type,
    async: async_status,
    datType: "json",
    timeout: 10000,
    success: function(data){
        DEBUG && console.log("[OK] .", data);

        // Show error messages from server if they exist
        if (data.status == "failure"){
            if (data.code == "104"){
                alert("Your session has expired. Please login again.");
                logout();
            }
        }
        // Check the status is correct
        else {
            tutorialInfo_data = data;
        }
    },
    error: function(data){
        DEBUG && console.log("[FAIL] Request failed.");
        failed = true;

        // If request failed, display message
        alert("Sorry, something went wrong.\n\nPlease try again later.");

    },
    complete: function(){
        hideModal();
        busy=false;
    }
})