angularjs $http调用接口的方式详解
更新时间:2018年08月13日 09:04:14 作者:寒山石径
今天小编就为大家分享一篇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);
})
var promise = $http({
method: 'GET',
url: '/api/users.json'
});
promise.then(function(resp) {
// resp是一个响应对象
}, function(resp) {
// 带有错误信息的resp
});
var promise = $http({
method: 'GET',
url: '/api/users.json'
});
promise.success(function(data, status, headers, config) {
// 处理成功的响应
});
promise.error(function(data, status, headers, config) {
// 处理非成功的响应
});
以上这篇angularjs $http调用接口的方式详解就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。
相关文章
解决angular的$http.post()提交数据时后台接收不到参数值问题的方法
这篇文章为大家分享了解决angular的$http.post()提交数据时后台接收不到参数值问题的方法,感兴趣的小伙伴们可以参考一下2015-12-12
解决三元运算符 报错“SyntaxError: can''''t assign to conditional expre
在本篇文章里小编给大家整理的是关于python三元运算符 报错“SyntaxError: can't assign to conditional expression”的处理方法,需要的朋友们学习下。2020-02-02


最新评论