How to assign value to global variable
function ok(){
var idglobal;
$.get("<?php echo base_url('testchat/rtc/showchat'); ?>", function (data) {
data = $.parseJSON(data);
$.each(data, function (i, item) {
idglobal = item.id;
});
});
}
console.log(idglobal);
above this code to assign value to global variable but the result is undefined