關於AngularJs中$http post、get 傳送和接受引數詳解
阿新 • • 發佈:2019-02-03
1、POST、GET攜帶引數的寫法不一樣,如下:
?1 2 3 4 5 6 7 |
$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,
status, headers, config){ console.error( '我錯了' );
});
|
1 2 3 4 |
$http({method: 'GET' ,url: './topic/getTopicCommentList' ,
params:{topicId:$stateParams.topicId}
}).success( function (data,
status, headers, config) {})
.error( function (data,
status, headers, config){});
|
- 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.