AJAX基础
2021/7/17大约 2 分钟
AJAX基础
npm init -y
npm i expreess //使用express框架








JSON.stringify(Object)转化为str

JSON.parse(xhr.response) (手动还原)

xhr.responseType='json' (自动还原)

nodemon安装与使用 终端命令:
npm install -g nodemon
nodemon ___.js //服务端数据改变,不刷新,自动更换页面IE浏览器缓存问题解决

xhr.timeout= ;
xhr.ontimeout=function(){ };

xhr.onerror=function(){ };

超时
重复发送
$('button').eq(0).click(function(data){
console.log(data);
},'json')get请求
post请求


直接用BootCDN引入Axios crossorigin="annoymous"
get


post


协议,域名,端口必须完全相同

jsonp只支持get请求
网页有些标签天生具备跨域能力,如:img,link,iframe,script,








