search

Home  >  Q&A  >  body text

angular.js - Angular Js 或者Jquery 发送POST请求,如何进行跨域 ?客户端如何解决 ?

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

过去多啦不再A梦过去多啦不再A梦2745 days ago642

reply all(6)I'll reply

  • PHP中文网

    PHP中文网2017-05-15 17:02:56

    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.

    reply
    0
  • 黄舟

    黄舟2017-05-15 17:02:56

    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!

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-15 17:02:56

    jquery has a setting dataType:'jsonp', and then the url absolute address

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-05-15 17:02:56

    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

    reply
    0
  • 怪我咯

    怪我咯2017-05-15 17:02:56

    jsonp or http://www.ruanyifeng.com/blog/2016/04/cors.html

    reply
    0
  • ringa_lee

    ringa_lee2017-05-15 17:02:56

    The front end requests the local backend server (php) -> The backend requests the cross-domain interface through CURL

    reply
    0
  • Cancelreply