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

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

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

data:{content:content,mailOrqq:mailOrqq,type:'chat-page-feedback'}网站

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

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

}).error(function(data, status, headers, config){code

console.error('我错了');get

});string

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

params:{topicId:$stateParams.topicId}

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

       .error(function(data, status, headers, 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.io

相关文章
相关标签/搜索