加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

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

发布时间:2020-12-17 09:21:45 所属栏目:安全 来源:网络整理
导读:$http.get请求数据的格式 [js] view plain copy $http.get(URL,{ params:{ "id" :id } }) .success( function (response,status,headers,config){ }) $http.post请求数据的格式 copy $http.post(URL,248); line-height:18px; margin:0px!important; padding:

$http.get请求数据的格式

[js] view plain copy
  1. $http.get(URL,{
  2. params:{
  3. "id":id
  4. }
  5. })
  6. .success(function(response,status,headers,config){
  7. })

$http.post请求数据的格式

copy
    $http.post(URL,248); line-height:18px; margin:0px!important; padding:0px 3px 0px 10px!important"> "id":id
  1. tips:

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

    [java] copy
      //分享商品list列表
    1. .factory("shareGoodsListService",["$http",function($http){
    2. return{
    3. //得到所有的收货地址
    4. updateAddress:function(__scope__,addrid){
    5. //获取地址的值
    6. varProvince=$("select[name='Province']").val();
    7. varCity=$("select[name='City']").val();
    8. varArea=$("select[name='Area']").val();
    9. varformData={
    10. id:addrid,
    11. name:__scope__.formData.name,
    12. mobile:__scope__.formData.mobile,248); line-height:18px; margin:0px!important; padding:0px 3px 0px 10px!important"> province:Province,108); list-style:decimal-leading-zero outside; color:inherit; line-height:18px; margin:0px!important; padding:0px 3px 0px 10px!important"> city:City,248); line-height:18px; margin:0px!important; padding:0px 3px 0px 10px!important"> area:Area,108); list-style:decimal-leading-zero outside; color:inherit; line-height:18px; margin:0px!important; padding:0px 3px 0px 10px!important"> address:__scope__.formData.address,248); line-height:18px; margin:0px!important; padding:0px 3px 0px 10px!important"> zip:__scope__.formData.zip,108); list-style:decimal-leading-zero outside; color:inherit; line-height:18px; margin:0px!important; padding:0px 3px 0px 10px!important"> submit:"submit"
    13. };
    14. $http.post("{:U('AddressInfo/editAddress')}",formData).success(function(response,153); background-color:inherit; font-weight:bold">if(response.status==1){
    15. alert("修改成功!");
    16. }
    17. })
    18. },248); line-height:18px; margin:0px!important; padding:0px 3px 0px 10px!important"> getAddress:function(){
    19. //$http.get方法传递参数使用的是{params:jsonObj}
    20. $http.get("{:U('AddressInfo/editAddress')}",{
    21. params:{
    22. .success(function(response,config){
    23. //获取地址的数据
    24. __scope__.formData={
    25. name:response.data.name,248); line-height:18px; margin:0px!important; padding:0px 3px 0px 10px!important"> mobile:response.data.mobile,108); list-style:decimal-leading-zero outside; color:inherit; line-height:18px; margin:0px!important; padding:0px 3px 0px 10px!important"> address:response.data.address,248); line-height:18px; margin:0px!important; padding:0px 3px 0px 10px!important"> zip:response.data.zip
    26. };
    27. //默认收货地址的值
    28. newPCAS("Province","City","Area",response.data.province,response.data.city,response.data.area);
    29. }])

    (编辑:李大同)

    【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读