HTML Web Worker and Jquery Ajax call

后端 未结 6 1217
夕颜
夕颜 2020-11-30 06:19

I\'m wondering if I can use jQuery inside the web worker file. Google Chrome gives me this error: \"Uncaught ReferenceError: $ is not defined\".

Here is the code: Th

6条回答
  •  攒了一身酷
    2020-11-30 07:10

    jQuery is mostly for working with the DOM and working with web pages. So it is not so suitable for Web Workers that do not have access to the DOM.

    You might want to use a utility library instead of a DOM library, such as underscore.js, or perhaps someone ought to make a jQuery Worker library, a stripped down light version of jQuery without all the DOM manipulation functionality, just keeping the utility functions.

提交回复
热议问题