I am using this Web worker which has a Global variable declared in it. Can I access the same (Global variable in worker 1) in the newly spawned web worker(worker 2)?
When I've tried using jQuery in web worker, I get error "window is not defined". Is there any way to use jQuery in a Web Worker
?
importScripts('jquery-latest.js');
function fetch_ajax(url) {
$.ajax({
type: 'GET',
url: url,
success: function(response) {
postMessage(response);
}
});
}
fetch_ajax('test.txt');
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…