angular用$http请求数据
来源:互联网 发布:上师大网络教育 编辑:程序博客网 时间:2024/06/05 07:54
项目中用到$http
请求数据接口像jQuery里的$ajax一样分为post请求和get请求.
get请求:
$http({ url:url1, //接口地址 method: 'get'}).success(function(data){ //请求成功 console.log("成功");}).error(function(){ //请求失败 console.log("失败");})
或者
$http.get('js/faHuosp.json') //本地的假数据地址.then(function successCallback(response) { //console.log("我是success");}, function errorCallback(response) { //console.log("我是error")});
post请求:
$http({ url:url1, //接口地址 method: 'post', data: data1, //传的数据}).success(function(data){ //请求成功 console.log("成功");}).error(function(){ //请求失败 console.log("失败");})
或者:
$http.post(url,data) //url为请求的地址,data为传输的数据.then(function successCallback(response) { //console.log("我是success");}, function errorCallback(response) { //console.log("我是error")});
(注:第二种方法中的successCallback和errorCallback是可以自行命名的,放在该位置就会认为是成功或失败的回调。)
0 0
- angular用$http请求数据
- Angular----$http请求数据
- angular-请求数据
- angular的http请求方式
- angular中的http请求封装
- Angular-$http请求后台php接收方法
- ionic/angular $http post form-data请求
- angular的http三种请求方式
- Angular学习:http请求失败的问题
- Angular $http拦截器计算请求耗时
- ajax请求和angular js中http请求
- http,请求网络数据
- Http百度请求数据
- HTTP数据请求
- Http请求网络数据
- Http网络请求数据
- Angular JS中数据交互-$http
- $http——ajax跨域请求的angular方式
- shell script
- 获取“li”的索引号
- Go语言 IDE之Gogland配置使用
- The Knowledge of Linux-.-Day14
- C++中类成员函数作为回调函数 [转]
- angular用$http请求数据
- Java源码阅读思路
- 博客迁移声明
- 设计模式六大原则
- Logstash的logstash-input-jdbc插件mysql数据同步ElasticSearch及词库
- java控制double输出的小数点位数
- Caffe 训练出现 loss = 1.#QNAN 的解决方法。
- Android Studio 好用的插件
- 乡韵