You can control this via HTTP header by adding Access-Control-Allow-Origin
. Setting it to *
will accept cross-domain AJAX requests from any domain.
Using PHP it's really simple, just add the following line into the script that you want to have access outside from your domain:
header("Access-Control-Allow-Origin: *");
or whatever methods you have available in libraries like Guzzle or Http Foundation to manage HTTP requests
Don't forget to enable mod_headers module in httpd.conf.