关于AngularJs中$http post、get 发送和接受参数详解

前端之家收集整理的这篇文章主要介绍了关于AngularJs中$http post、get 发送和接受参数详解前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

关于AngularJs中$http post、get 发送和接受参数详解

$http({method: 'post',url: './Feedback/mail',

data:{content:content,mailOrqq:mailOrqq,type:'chat-page-Feedback'}

}).success(function(data,status,headers,config) {

console.log("IT部落是个神奇的网站");

}).error(function(data,config){

console.error('我错了');

});

$http({method: 'GET',url:'./topic/getTopicCommentList',

params:{topicId:$stateParams.topicId}

       }).success(function(data,config) {})

       .error(function(data,config){});

聪明的你一定看出来了,POST最好用Data携带数据、GET最好用params携带数据,两者使得区别如下描述: params – {Object.<string|Object>} – Map of strings or objects which will be serialized with theparamSerializer and appended as GET parameters.data – {string|Object} – Data to be sent as the request message data.

原文链接:https://www.f2er.com/angularjs/147732.html

猜你在找的Angularjs相关文章