Can someone please explain to me why and if it is the desired behavior that the following code WILL NOT ALWAYS alert the same value twice in a row when visiting webpages assuming a small delay in clicking “ok” on the alert box?
Usual simple extension set up with the following code in background.js:
chrome.webRequest.onBeforeRequest.addListener(function(request) {
alert(request.requestId);
alert(request.requestId);
return {};
}, {urls: ["*://*/*"]}, ["blocking"]);
I just cannot get this. I need the same value to pop up twice because I will be doing AJAX requests and I cannot permit myself to have variables changing behind my back with potential delays in AJAX…
If it is the desired behaviour how can I make sure this does not happen? Would closures help?
Thanks
1 Answer