jQuery使用ajax
1.导入jQuery的js库
2.jQuery发送单一的get请求
$.get(
url:'接口地址',
data:{
id:1,
name:2,
......
}
function(res){
// res是服务器返回的数据
}
)
3.jQuery发送单一的post请求
$.post(
url:'接口地址',
data:{
id:1,
name:'哈哈哈',
......
}
function(res){
// res是服务器返回的数据
}
)
4.jQuery发送符合Ajax请求
$.ajax({
type:'GET or POST',
url:'接口地址',
data:{
id:1,
name:'哈哈哈',
......
}
success:function(res){
// res是服务器返回的数据
}
})
从一个小白开始做起,努力做一个美国总统