Wrap postmessage inside ajax call.