在jQuery中使用$.ajax可以发送get请求:
$.ajax({
url:"ajax.json",
type:"get",
success:function(rep){
console.log(rep.habby);
}
})
//请求成功时执行done函数,失败时执行fail函数
$.ajax({}).done(function(){}).fail(function(){{})
例如:
$.ajax({type:"get",url:"txt1.txt"}).done(function(resp){
console.log(resp)
return $.ajax({url:"txt2.txt"});
}).done(function(resp){
console.log(resp);
return $.ajax({url:"txt3.txt"});
}).done(function(resp){
console.log(resp);
})