importScripts('js/jquery.js');
importScripts('js/jquery.mobile-1.2.0.js');
importScripts('cordova.js');
importScripts('DataBase.js');
importScripts('SaveData.js');
self.addEventListener('message', function(e) {
queryDB(function(arr) {
self.postMessage(e.data + arr);
});
}, false);
here i tried to retrieve data from database and show in parent page using html 5 worker thread.But i get following error.
Uncaught ReferenceError: window is not defined
You cannot importScript jQuery, because jQuery requires DOM access, which web workers don't have.
If you experience this error with Web Workers using importScripts functionality, it's because the script you're importing may be referencing window object; this is not supported in Web Workers.
To fix this, do the following:
var _window = this || self || window;
The above ensures that self (which is compatible with Web Workers) is called before unsupported window.
window with _window.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With