var IAP_loaded = false; // Global Scope
var IAP_onReady = function(){
storekit.load(IAP_list, function (products, invalidIds) {
IAP_loaded = true;
console.log("1] -- IAP Loaded: "+IAP_loaded); // Outputs true
});
console.log("2] -- IAP Loaded: "+IAP_loaded); // Outputs false
IAP_loaded = true;
console.log("3] -- IAP Loaded: "+IAP_loaded); // Outputs true
};
console.log("4] -- IAP Loaded: "+IAP_loaded); // Outputs false
For some my global variables aren't staying modified outside the function itself... I created a completely separate function and changed a global variable and it works fine. This just mind baffles me. Any thoughts?
PS. This is a Phonegap 3.0 project and the callback function is from IAP plugin. Found here https://github.com/j3k0/PhoneGap-InAppPurchase-iOS
storekit.load is Asynchronous! Thanks for narrowing it.
2] -- IAP Loaded: false
3] -- IAP Loaded: true
4] -- IAP Loaded: false
1] -- IAP Loaded: true
I get back the response in that order. But it is not Ajax. It's through Objective C, the javascript just handles the responses so it's editable through javascript