2021年1月6日星期三

How to use variable within callback function in Chrome Extension background script?

I'm trying to use variable el in callback function as below.

    var el =getElement();      xhr.onload = function() {        if (xhr.status != 200) {          alert(`Error ${xhr.status}: ${xhr.statusText}`);         } else {           alert(`Done, got ${xhr.response} bytes`);           alert(el); << this line        }      };  

how can I get 'el' available for alert(el) in else statement?

https://stackoverflow.com/questions/65606134/how-to-use-variable-within-callback-function-in-chrome-extension-background-scri January 07, 2021 at 11:08AM

没有评论:

发表评论