📜  javascript 将 json 传递给全局变量 - Javascript 代码示例

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

代码示例1
//**
//Remove the var keyword on global_datalength to make it global.
//**
//You can also use window.global_datalength.
//**
//Another way is to declare the variable outside the jQuery ready function.
//**

function leavereminder() {
    $.ajax({
        dataType: "json",
        url: "home/leavereminder",
        async: false,
        success: function(data) {
            if(data.length != 0) {
                for(x=0; x';  
                    lblm.className = 'alert alert-info';                  
                    document.getElementById('notifbody').appendChild(lblm);           
                }
            }
            global_datalength = datalength;
        },
    });
}