Files
ClassContent/历届学生/font-end-nine/每天上课/2022-06-26/笔记.txt
2024-09-27 02:06:13 +08:00

85 lines
1.6 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

前后端数据交互的工具:
ajax
无刷新 的数据交互方式
http
请求头
存放着,发送此次请求的客户端的一些基本信息
例如:什么设备 user-agent发送了多长的数据在什么时间发送的是否需要压缩数据来传输
content-length
https://www.cnblogs.com/smallzhen/p/14094928.html
响应头
存放着,响应此次请求的服务端的一些基本信息
https://blog.csdn.net/qq_30953791/article/details/114002893
请求体
请求状态码
https://blog.csdn.net/m0_56227492/article/details/123101337
请求方式:
GET 要
参数:
http://127.0.0.1/index.php?id=1&page=2&key=value
缺点:不是和提交一些敏感数据
POST 给
http://127.0.0.1/index.php
请求体里面
multipart/form-data; 上传文件
application/x-www-form-urlencoded;
application/json;
PUT 更新
DELETE 删除
OPTIONS 预检查 留坑
ajax 浏览器 同源策略
绕过同源策略:跨域
前端网址:
http://127.0.0.1:8080/index.html
后端接口地址
http://192.168.31.1:9090/index.php
协议 http 80 http 443
域名
端口
三种解决方案:
1: 后端设置请求头,允许跨域 cors
2: jsonp 把ajax请求伪装成 js文件请求绕过 同源策略 达到 发送请求 的目的,通过 回调函数 拿回数据
3: 服务端代理
A 前端 ---> B 别人的后端
A 前端 ---> C 自己的后端 ---> B 别人的后端
服务端渲染
前后端分离