IndexedDB with Web Workers
<html> | |
<body> | |
<span id="output"></span> | |
</body> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> | |
<script src="main.js"></script> | |
</html> |
self.onmessage = function(event) { | |
var req = indexedDB.open('mydb', 1); | |
req.onupgradeneeded = function (e) { | |
self.postMessage('successfully upgraded db'); | |
}; | |
req.onsuccess = function (e) { | |
self.postMessage('successfully opened db'); | |
}; | |
req.onerror = function(e) { | |
self.postMessage('error'); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
Nice example. Does "req" only work inside of self.onmessage? I tried putting it all inside a function inside worker.js that self.onmessage calls but it fails to call "onsucess"? any ideas?