i use for loop for check validation if data get success then data will store in one variable i want to console that variable after execute for loop but currently in my code that variable call before for loop i use this code
function UpdateOnlineDriver(data) {
    console.log(data);
    onlinedriverdata = [];
    var sessionvar =  $('#getsession').val();    
    if(sessionvar == '2'){
        for (var i = 0; i < data.length; i++){        
            var ddata = data[i];
            $.ajax({
                type:"post",
                url: "data/chk_baseadmin.php",
                data: {did:data[i][0]}
            }).success(function(data){
                //console.log(data);
                if(data == 'yes'){
                    console.log(ddata[0]);
                    onlinedriverdata.push([ddata[0],ddata[1],ddata[2],ddata[3],ddata[4]]);
                }  
            });        
        }
    }
    else{
        onlinedriverdata = data;
    }   
    console.log(onlinedriverdata);
}
when execute this function console vareable first then execute for loop i want to console that variable after complete execute for loop so give me proper solution for this issue
 
    