When the two domains are not the same, I checked some methods on the Internet, but I still felt that it was not very good. I did not come up with a good solution to this problem!
There are roughly three methods on the Internet:
1. the most humane approach-Manual settingIn the browser settings, select "tick" for cross-origin ". A few people can use it. Too many are not feasible at all!Pass!
2. create a proxy on the server of the same domain. The browser sends a request to the proxy URL. Then, the proxy sends a request to the URL of another domain. After obtaining a response, for processing or sending them back to the browser as they are.
I don't know how it works, but intuition tells me a lot of problems, such as security and speed. In the final analysis, we still need to rely on the server. If there is a problem with the server, it will be useless!
Pass or (considerations)
3. Use the on-demand Javascript script. Generate a new <SCRIPT> dynamically on the page and direct its src attribute to the website of another website. The content returned by this website must be a legal Javascript script, which is commonly used for JSON messages.
I tried this method, but it still doesn't work. If someone else sets something for the server in another domain, it doesn't work!Pass!
Therefore, I have to ask you how to solve cross-origin problems? It is best not to write a proxy (I personally think there are many restrictions on the server and there are many security risks !), Is there a way to directly useCodeYou can solve this problem!