我有一个网络工作者,请参阅下文。
var worker_script = function(){
self.onmessage = function(e){
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
postMessage(xhttp.responseText);
counter = 0;
}
};
xhttp.open("GET",e.data, true);
xhttp.send();
}
}
var search_worker = new Worker(URL.createObjectURL(new Blob(["("+worker_script.toString()+")()"], {type: 'text/javascript'})));
// post message to worker
search_worker.postMessage("https://www.connectnigeria.com/ajax/getkeywords?keyword=");
search_worker.onmessage = function(e){
console.log(e);
};
这在我的本地服务器上工作,但是在我的生产服务器上,它给了我这个错误
未捕获的DOMException:无法在'XMLHttpRequest'上执行'open': self.onmessage上的URL无效 (blob:https://mywebsitesample.com/d17ebd88-7452-4282-9313-26d697fea457:1:198)
可能是什么问题?有什么想法吗?