What I am trying to achieve:
To be able to embed the below code on a client domain, let’s say client.com which makes a call to the apidomain.com. The client.js script on the apidomain makes an ajax call to a PHP file app.php which is also hosted on apidomain.com. Once the call is made, options are applied and the PHP file responds with the data which is embedded on the client side page.
<script type="text/javascript" src="http://apidomain.com/client.js">
var api_key = 'key';
var opts = true;
</script>
I have the JS and the PHP setup, however everytime the client.js makes a request to the app.php it returns blank, even though the post data goes through. Is this problem related to cross domain ajax request? What would be the correct setup?
You should use this technique its called JSONP. So in a few words:
So when your script from app.php will be loaded it call someFunction(‘example param1’, ‘example param2’) with parameters you created in app.php