AJAX request from one subdomain to another subdomain, but in the same domain

I know that you cannot do cross-domain ajax requests unless you use a single proxy server.

However, if I made an ajax request from server1.example.com to server2.example, would this not work even if it was in the same domain as example.com?

I'm sure sites like YouTube make ajax requests to different servers. e.g. a request from youtube.com to vs1022.youtube.com etc.

Any clarification on this would be excellent. Thank you for your time.

+6
javascript ajax cross-domain
source share
2 answers

server1.example.com and server2.example.com considered as a cross-domain for an AJAX request.

You will need to set the Access-Control-Allow-Origin: * header on the server side.

+4
source share

The Access-Control-Allow-Origin: * header should be generated using a set of whitelists maintained by the web service provider if the web services do not check requests using auth tokens.

0
source share

All Articles