欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

angularJS 发起$http.post和$http.get请求

程序员文章站 2022-04-15 17:34:25
...

https://www.cnblogs.com/doforfuture/p/5641909.html

http://blog.csdn.net/fengzijinliang/article/details/51897991

https://www.cnblogs.com/jyybeam/p/6122346.html

用post提交,后台接收不到参数的问题

$http({  
   method:'post',  
   url:'post.php',  
   data:{name:"aaa",id:1,age:20},  
   headers:{'Content-Type': 'application/x-www-form-urlencoded'},  
   transformRequest: function(obj) {  
     var str = [];  
     for(var p in obj){  
       str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));  
     }  
     return str.join("&");  
   }  
}).success(function(req){  
       console.log(req);  
})