1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > angularjs $http.get 和 $http.post 传递参数

angularjs $http.get 和 $http.post 传递参数

时间:2019-12-14 17:15:37

相关推荐

angularjs $http.get 和 $http.post 传递参数

$http.get请求数据的格式

[js]view plain copy$http.get(URL,{ params:{ "id":id } }) .success(function(response,status,headers,config){ })

$http.post请求数据的格式

[js]view plain copy$http.post(URL,{ "id":id }) .success(function(response,status,headers,config){ })

tips:

get 和 post方法传递参数的方式不一样。

[java]view plain copy//分享商品list列表 .factory("shareGoodsListService",["$http",function($http){ return{ //得到所有的收货地址 updateAddress:function(__scope__,addrid){ //获取地址的值 varProvince=$("select[name='Province']").val(); varCity=$("select[name='City']").val(); varArea=$("select[name='Area']").val(); varformData={ id:addrid, name:__scope__.formData.name, mobile:__scope__.formData.mobile, province:Province, city:City, area:Area, address:__scope__.formData.address, zip:__scope__.formData.zip, submit:"submit" }; $http.post("{:U('AddressInfo/editAddress')}",formData).success(function(response,status,headers,config){ if(response.status==1){ alert("修改成功!"); } }) }, getAddress:function(){ //$http.get方法传递参数使用的是{params:jsonObj} $http.get("{:U('AddressInfo/editAddress')}",{ params:{ "id":id } }) .success(function(response,status,headers,config){ //获取地址的数据 if(response.status==1){ __scope__.formData={ name:response.data.name, mobile:response.data.mobile, address:response.data.address, zip:response.data.zip }; //默认收货地址的值 newPCAS("Province","City","Area",response.data.province,response.data.city,response.data.area); } }) } } }])

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。