---恢复内容开始---
什么是ajax?
ajax就是前后台数据交互依赖的一种技术。
ajax的本质就是xmlHttpRequest对象
如果需要将请求发送到服务器,我们要使用XMLHttpRequest对象的open()和send()方法
open方法桂清请求的类型以及路径和是否异步处理请求,所以有三个参数,
1:method:请求的类型,GET或POST
2:url:路径
3:async:true或false
send()方法则是将请求发送到服务器
当请求发送到服务器时,我们需要执行一些任务:
onreadystatechange:存储函数,每当readyState属性改变时,就会调用该函数
readyState:请求的五个阶段
是
responseText:返回的文件内容
status:状态码 简单说下:
200;成功了
3xxx:代表禁用的意思
404:代表文件没有找到
5xx:代表服务器的问题
这是我写的一个封装的ajax
调用传参就可以使用了
对于ajax我也是刚接触,理解不是太深,还会再次修改的,如有错误请评论留下来
---恢复内容结束---