-
Notifications
You must be signed in to change notification settings - Fork 3
Home
Plugin can be used to dynamically load content from same or other domains. Also, it can post form data to remote server side script (php, asp, perl – whatever you use). It’s creating a hidden iframe object to fetch remote page and when remote page sends data (either via window.postMessage in all modern browsers or via window.name in IE 6 & 7), data is read and callback method is invoked.
Simple usage:
$.getRemoteData(
function(data){
$("body").append( data );
},
'http://-some-remote-url-/source.html'
);In source page one must add code like this (as last body element),
to enable cross domain data fetch:
<script type="text/javascript"> window.name = $("body").html(); try { var target = parent.postMessage ? parent : (parent.document.postMessage ? parent.document : undefined);if (typeof target != "undefined") { target.postMessage($("body").html(), "*"); } } catch (e) {/**/} </script>
For simple demo, try this:
Download the source code of the repository and load index.html in your favorite browser. The source.html file is loaded from github server. You can also upload index.html to your web server that is on different domain.