Right now, I've got this, and it works:
var myWebWorker = new Worker('myWebWorker.js');
myWebWorker.onmessage = function (myEvent) {
$('#Print').append('Return value: ' + myEvent.data + "<br>");
};
myWebWorker.postMessage(2);
My question is: Can I do this instead?
var result = myWebWorker.postMessage(2);
Because I need the web worker to be synchronous - in other words, give a return value and also don't return until you're finished.
Edit 1:
The web worker is doing an insert/select onto a local database using openDatabaseSync transactions.
Edit 2:
It appears that my problem is with Cocoa Touch and not with JavaScript. Here's a clever hack that someone has posted on StackOverflow.
Edit 3:
Here's a better hack.