Вызов HTML Web Worker и JQuery Ajax

Мне интересно, могу ли я использовать jQuery внутри файла веб-воркера. Google Chrome выдает такую ​​ошибку: «Uncaught 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);
}

Рабочий файл:

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
 */
loadRss = function () {
  $.ajax({
    data: {city: CITY_LOCATION},
    url: BASE_URL + "/getfeeds",
    onsucess: function (data) {

    }
  });
}

Пожалуйста, помогите, спасибо :)

40
задан Fred 2 September 2013 в 13:20
поделиться