A simple way to do this is to have your PHP script return something like:
callback_function(YOUR_DATA);
Then, in the JS script included in the client site, you dynamically insert <script> , where src points to your PHP script:
(function() { var scriptElement = document.createElement('script'); scriptElement.type = 'text/javascript'; scriptElement.async = true; scriptElement.src = 'http://example.org/yourScript.php?data=...'; var container = document.getElementsByTagName('script')[0]; container.parentNode.insertBefore(scriptElement, container); })();
This method is called JSONP and should do exactly what you want;)
Another way to solve the problem is to enable cross-domain XMLHttpRequest in the content security policy. But I think that only Firefox 4 supports this right now.
NikiC source share