Jump to content

PostMessage Receiver - How to retrieve the PostMessage


chinoknot

Recommended Posts

Hello, 
I need your help. I wrote about this thing two months ago, but without useful answer, now I need to complete this work. I understood better how it works, but I need the last thing. 

I try to explain my problem: I need to receive a "post" from another domain, but I can't understand how can I do this, because the sender send me a json and I need to get in my receiver. This is my code:

<script>
//create popup window
var domain = 'http://10.5.15.145';
var myPopup = window.open(domain + '/Apps/post/child_backup.php','myWindow



//periodical message sender
setTimeout(function(){
var message = JSON.stringify({action: "redirect", vendor_id :"45" });
console.log('blog.localending message: ' + message);
myPopup.postMessage(message,domain); //send the message and target URI
},1000);

//listen to holla back
window.addEventListener('message',function(event) {
if(event.origin !== 'http://10.5.15.145') return;
console.log('receivedponse: ',event.data);
},false);
</script>

Now the vendor_id is "45" for a test. They pass to me vendor_id: xxxx. 

how can I grab this value from the post?


Thank you in advance.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.