The problem of cross-domain cannot be solved by pure front-end. It definitely requires the cooperation of the back-end. Think about it, if cross-domain can be solved by just changing some configurations on the front-end, can restricting cross-domain still ensure security?
1.CORS only needs to configure the response header in the background. In the development environment, if the server side is not configured, can we still happily cooperate in development?
2. JSONP is not useless, it is definitely useful, and it is also one of the methods to solve cross-domain problems, but it also requires the cooperation of the backend, and the data content returned to the frontend needs to be modified and made into the form of jsoncallback(fn). The author needs to figure it out himself. The principle of JSONP works.
At present, there are two mainstream methods to solve cross-domain problems.
As long as it is cross-domain, it cannot be solved by pure front-end. Because of the restrictions of the same-origin policy. As long as it is cross-domain, strong cooperation on the server side is required. No matter what method you use! As long as it is cross-domain, strong cooperation on the server side is required. No matter what method you use! As long as it is cross-domain, strong cooperation on the server side is required. No matter what method you use!
If the domain names of the two people are different, you can only let the backend add response headers or write the backend code yourself and call his interface through the backend
The problem of cross-domain cannot be solved by pure front-end. It definitely requires the cooperation of the back-end. Think about it, if cross-domain can be solved by just changing some configurations on the front-end, can restricting cross-domain still ensure security?
1.CORS only needs to configure the response header in the background. In the development environment, if the server side is not configured, can we still happily cooperate in development?
2. JSONP is not useless, it is definitely useful, and it is also one of the methods to solve cross-domain problems, but it also requires the cooperation of the backend, and the data content returned to the frontend needs to be modified and made into the form of jsoncallback(fn). The author needs to figure it out himself. The principle of JSONP works.
At present, there are two mainstream methods to solve cross-domain problems.
As long as it is cross-domain, it cannot be solved by pure front-end. Because of the restrictions of the same-origin policy.
As long as it is cross-domain, strong cooperation on the server side is required. No matter what method you use!
As long as it is cross-domain, strong cooperation on the server side is required. No matter what method you use!
As long as it is cross-domain, strong cooperation on the server side is required. No matter what method you use!
jquery has a setting dataType:'jsonp', and then the url absolute address
If the domain names of the two people are different, you can only let the backend add response headers
or write the backend code yourself and call his interface through the backend
jsonp or http://www.ruanyifeng.com/blog/2016/04/cors.html
The front end requests the local backend server (php) -> The backend requests the cross-domain interface through CURL