Browsers will compare two URLs to determine the origin based on a number of factors. These factors include the domain name, the application layer protocol, and in many browsers, the port used.
Table A-1. Results of making an AJAX request from a script on http://www.site.com/page1.html
Same host and protocol
Different protocol (https)
Different host (not an exact match)
Different host (subdomain)