javascript - Global variable sometimes does not update in fbAsyncInit -
i have code :-
var fb_init = false; window.fbasyncinit = function() { fb.init({ appid: 'xxxxxxxxxxxxx', xfbml: true, version: 'v2.2' }); fb_init = true; };
now, when user clicks login button, check if fb api has loaded. example :-
function checklogin(){ if (!fb_init) { alert("not loaded!"); }else{ login(); } }
but, face confusing problem here. if user clicks login button after api has loaded, works fine. if, chance, user clicks login button before api has loaded, gets alert box everytime clicks login button again even after api has loaded. checked fb_init
in firefox console printing console.log(fb_init)
in js console in browser , false
. doing wrong here?
Comments
Post a Comment