angularjs $http调用接口的方式详解
如下所示:
$http.get("/merchantmall/merchant.json")
.success(function(data,status,headers,config){
console.log(arguments);
})
.error(function(data,status,headers,config){
console.log(arguments);
})
$http({url:"/merchantmall/merchant.json",})
.success(function(data,status,headers,config){
console.log(arguments);
})
.error(function(data,status,headers,config){
console.log(arguments);
})
varpromise=$http({
method:'GET',
url:'/api/users.json'
});
promise.then(function(resp){
//resp是一个响应对象
},function(resp){
//带有错误信息的resp
});
varpromise=$http({
method:'GET',
url:'/api/users.json'
});
promise.success(function(data,status,headers,config){
//处理成功的响应
});
promise.error(function(data,status,headers,config){
//处理非成功的响应
});
以上这篇angularjs$http调用接口的方式详解就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持毛票票。
热门推荐
10 小红书平安祝福语简短
11 生日祝福语大全女孩简短
12 收生日红包祝福语 简短
13 领证幽默祝福语简短
14 法考面试祝福语简短
15 老哥出门祝福语简短语
16 送灯祝福语简短独特
17 幼儿狗年祝福语大全简短
18 好听的元旦简短祝福语