Return value from event handler into parent function from javascript
<p>I need to have a value returned by and event handler into the function that initiates the event in the first place, just to return the value that will be received only in the event handler. I believe there should be an easy way to accomplish this or to attack the problem from a different angle.</p>

<p><b>What I actually need to do is:</b></p>

<ol>
<li>Create a new img DOM object to feed dataURL into (the dataURL is coming from canvas.toDataURL())</li>
<li>img.onload will let me return the dataURL</li>
</ol>

<p>I'm using jQuery if that helps somehow but don't have to of course.</p>

<p>In my understanding I can't rely on the img to have the data immediately, and it feels stupid to use timeouts to wait for the event to fire and use some global variable, especially since a few might be processed in parallel.</p>

<p>For even more background, this is all for resizing images before (multi-)uploading them with HTML5 engine.</p>

<p>Thanks even for reading, and for any tips of course :)</p>

<p>Thanks,
Igor</p>
