Created
September 9, 2014 17:26
-
-
Save roman01la/e7a7b879698574c45ca0 to your computer and use it in GitHub Desktop.
Cross-origin solution for loading WebWorker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var xhr = new XMLHttpRequest(); | |
xhr.open('GET', url); | |
xhr.onload = function() { | |
if (xhr.status === 200) { | |
var workerSrcBlob, workerBlobURL; | |
workerSrcBlob = new Blob([xhr.responseText], { type: 'text/javascript' }); | |
workerBlobURL = window.URL.createObjectURL(workerSrcBlob); | |
var worker = new Worker(workerBlobURL); | |
} | |
}; | |
xhr.send(); |
i think your webworker only process data response from ajax, not execute call ajax in background.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
problem with this is if you do any relative xhr, it doesn't know where to go