Answers for "javascript pass json to global variable"

0

javascript pass json to global variable

//**
//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: "<?=base_url()?>home/leavereminder",
        async: false,
        success: function(data) {
            if(data.length != 0) {
                for(x=0; x<data.length; x++) {
                    var lblm = document.createElement('div');        
                    lblm.innerHTML = '<label>'+data[x]+'</label>';  
                    lblm.className = 'alert alert-info';                  
                    document.getElementById('notifbody').appendChild(lblm);           
                }
            }
            global_datalength = datalength;
        },
    });
}
Posted by: Guest on October-05-2021

Code answers related to "javascript pass json to global variable"

Code answers related to "Javascript"

Browse Popular Code Answers by Language