angular.js - Angular Js 或者Jquery 发送POST请求,如何进行跨域 ?客户端如何解决 ?
过去多啦不再A梦
过去多啦不再A梦 2017-05-15 17:00:56
0
6
638

我现在有个问题我前端用的是angular js , 后端在别人哪里 。我现在访问他的接口就是跨域了。
但是服务端的现在不给我设置CORS【服务端用的是spring web】 , 现在上头要我赶快整完 ,但是现在我弄前端 , 查了很多资料都是服务端解决的, 有些说用jsonp,但是根本就没用, 不知道有没有大神知道,在前端如何通过Jquery 或者 angular JS 完成跨域问题 ?

过去多啦不再A梦
过去多啦不再A梦

reply all(6)
Ty80

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template