I have some html5 postMessage code:
window.addEventListener("message", FA.recieveMessage, false);
That listener invokes this function:
FA.recieveMessage = function(e){
if (e.data == "closeFA"){
console.log("Type of data: "+e.data);
}
};
Now on ie8 this code doesnt work, cause it doesnt support html5 messaging. So I thought if there is a way to invoke that function by sending an ajax request of type jsonp!?
Is there a way to emulate messaging with jsonp?
if i do send jsonp request to another server, does it mean that it is a new request and it wont be aware of all the events that were triggered now?
UPDATE
Okay here is what I want. I want to close an iframe. So on one page, I have got this javascript:
$.ajax({url: 'http://api.apps.com/html/'+FA.appID,
data: {},
dataType: 'jsonp',
timeout: 10000,
jsonp: "closeIFrame"
});
This should instruct the apps/html page to invoke the closeIframe function is that right?
function closeIFrame() {
jQuery("#fa-iframe-container").fadeOut(300, function(){ jQuery(this).remove(); });
FA.bannerShown = false;
}
Yes technically you could emulate messaging with jsonp, each call will be a new request but the session will be available so the jsonp service could be state aware.
Update
In my experience you don’t call functions within a file instead each file represents a function so you may have services like:
http://example.com/add?message=hello
http://example.com/get