小编Tri*_*Tri的帖子

HTML Web Worker和Jquery Ajax调用

我想知道我是否可以在web worker文件中使用jQuery.谷歌浏览器给了我这个错误:"未捕获的ReferenceError:$未定义".

这是代码:父文件:

var loader = new Worker(BASE_URL + "js/rss_loader_worker.js");
// Ask the worker to start loading the RSS from the server
loader.postMessage("loadRss");
// When receive the response from the server
loader.onmessage = function (event) {
  console.log(event.data);
}
Run Code Online (Sandbox Code Playgroud)

工人档案:

onmessage = function (event) {
  if (event.data === "loadRss") {
    loadRss();
  }
}

/**
 * This function handles the AJAX request to the server side
 * then pass the content to the view page
 * @param none
 * @return html text …
Run Code Online (Sandbox Code Playgroud)

ajax jquery html5 web-worker

40
推荐指数
2
解决办法
4万
查看次数

标签 统计

ajax ×1

html5 ×1

jquery ×1

web-worker ×1