We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在了解ajax之前,我们先粗略的了解一下http协议
http事务
请求报文格式
get:
music.com
http/1.1
Accept:
Accept-Encoding:
Accept-Language
Cache-Control:
Cookie:
User- Agent
Get方法
响应报文格式
常用HTTP方法
GET
POST
PUT
DELETE
URL构成
常见http状态码
Ajax(Asynchronous JavaScript and Xml)
优点:
缺点:
ajax API
open开启一个请求
xhr.open('method',url[,async = true]) 参数: method: // GET/POST/DELETE/HEAD... url: // 我要请求的资源相对当前文档的路径 默认为true异步求情 : //false同步
setRequestHeader(非必须)
xhr.setRequestHeader(header,value) 参数: header: //Content-type
send正式向服务端发请求
xhr.send([data = null])
我们注意到前面的url都是相对当前文档的相对路径,是受ajax的同源策略影响的
两个页面拥有相同的协议(protocol),端口(port),主机(host),那么这两个页面你属于同一个源(origin)
相同的协议(protocol)
端口(port)
主机(host)
同一个源(origin)
可参考:跨域Frame代理
//弄一个状态锁 var AjaxLock = false; //事件触发下面代码 // ******start***** if (!AjaxLock){ AjaxLock = true; xhr.onreadystatechange = function(){ if( xhr.readyState == 4) { //do sth AjaxLock = false; //当接受完毕请求数据后将锁打开 } } //ajax配置 xhr.send(); } else { return; }
代码预览,需要开启mock-server数据
The text was updated successfully, but these errors were encountered:
No branches or pull requests
HTTP协议
http事务
请求报文格式
get:
http方法music.com
主机地址http/1.1
http版本Accept:
浏览器接收的媒体类型Accept-Encoding:
浏览器接收的媒体类型的编码方式Accept-Language
浏览器端接收的语言方式Cache-Control:
缓存策略Cookie:
发送cookie值User- Agent
浏览器的版本Get方法
请求体为空响应报文格式
常用HTTP方法
GET
POST
PUT
DELETE
URL构成
常见http状态码
ajax 是什么?有什么作用?
Ajax(Asynchronous JavaScript and Xml)
优点:
缺点:
ajax API
open开启一个请求
setRequestHeader(非必须)
send正式向服务端发请求
两个页面拥有
相同的协议(protocol)
,端口(port)
,主机(host)
,那么这两个页面你属于同一个源(origin)
可参考:跨域Frame代理
前后端开发联调需要注意哪些事情?后端接口完成前如何 mock 数据?
点击按钮,使用 ajax 获取数据,如何在数据到来之前防止重复点击?
**题目4:**实现加载更多的功能,效果范例415后端在本地使用server-mock来模拟数据
代码预览,需要开启mock-server数据
The text was updated successfully, but these errors were encountered: