Syntax error corrected.
Passing xhr (also named as "req") object as the third parameter to asynchronous callback implemented.
Calling postMessage on parent window (if available) instead of received postMessage source implemented.