📌  相关文章
📜  如何知道 ajax 是否正在运行 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:54.732000             🧑  作者: Mango

代码示例1
// site.js
$(function() {
    window.ajax_loading = false;
    $.hasAjaxRunning = function() {
        return window.ajax_loading;
    };
    $(document).ajaxStart(function() {
        window.ajax_loading = true;
          console.log('started')
    });
    $(document).ajaxStop(function() {
        window.ajax_loading = false;
          console.log('stopped')
    });
});
//logs in dev console whenever an ajax process starts and/or stops