Cross-origin and JSONP of AJAX (another function to automatically add a short address for the article) What is AJAX cross-origin request
For the sake of security, if you want to request the content of another website www. B .com via Ajax from www.a.com, the browser does not allow you to do this (I do not understand what security here refers? Think about what hackers can do without this restriction ). Under what circumstances is cross-origin? Domain names are different. For example, if a.com sends a request to B .com, this is, of course, cross-domain. This is not allowed. However, different subdomain names (for example, sub.a.com sends requests to www.a.com) or even different ports of the same domain name (for example, a.com: 80 sends requests to a.com: 8080) are also cross-domain.
The following is an example of cross-origin:
The Code is as follows: