当前位置:网站首页>解决跨域问题的三种方式
解决跨域问题的三种方式
2022-08-09 14:54:00 【小羊卷】
JSONP
原理:利用同源策略不拦截文件,在前端声明函数,在服务器端去调用函数,在调用的同时把数据以参数的形式传递过来。
优点:兼容任何浏览器
缺点:只有get请求,两端都要写代码,不是ajax请求
2.CORS - cross origin resource sharing
原理:在响应头中设置Access-Control-Allow-Origin:网页的地址或者通配符,通过同源策略的认证。
优点:前端不用谢代码,可以使用ajax请求
缺点:兼容性
3.反代理
原理:自己创建一个后端程序向接口发起请求,因为只有浏览器才有跨域问题,所以可以接收到数据,把自己的后端程序跟网页设置为同源,在用网页请求自己的服务器,就不会有跨域问题
优点:可以使用ajax请求
边栏推荐
猜你喜欢
随机推荐
It is deeply recognized that the compiler can cause differences in the compilation results
【超级账本开发者系列】专访——肖慧 : 不忘初心,方得始终
什么是模板引擎?常见的模板引擎有哪些?thymeleaf的常用指令介绍。
小型项目如何使用异步任务管理器实现不同业务间的解耦
WebGL:BabylonJS入门——初探:注入活力
Simple analysis of regularization principle (L1 / L2 regularization)
encapsulation of strlen(), strcpy(), strncpy(), strcat(), strncat(), strcmp(), strncmp() functions
How to achieve long-term benefits through the Tongdaxin quantitative trading interface?
股票程序化交易如何理解自己的交易系统?
量子力学初步
How do users correctly understand programmatic trading?
用户如何正确去认识程序化交易?
贝塞尔函数
方法学习笔记
注释,标识符,数据类型
What are the implications of programmatic trading rules for the entire trading system?
How to make your quantitative trading system have probabilistic advantages and positive return expectations?
OpenCV简介与搭建使用环境
Example of file operations - downloading and merging streaming video files
相干光(光学)



![[MySql]实现多表查询-一对一,一对多](/img/7e/8f1af4422a394969b28a553ead2c42.png)



