0
我正在構建一個接收POST數據的API並在Ruby on Rails 3中返回JSON。我使用angularjs $ http對象提交數據。參數與JSON字符串,同時設計與Rails的API用於AngularJS
var post_data = {
content: $scope.post_content,
authentication_token: csrf
};
$http({
url: feed_endpoint,
method: "POST",
'Content-Type': 'application/json',
params: post_data
}).success(function(post_data, status, headers, config) {
}).error(function(post_data, status, headers, config) {
$scope.status = status;
});
}
報價等的退讓用這種方法,我在和正在創建的JSON不正確的問題,而只是通過一個js數據對象(哈希)到$ http.data物體效果很好。
我在尋找任何方式的優點的輸入。
謝謝。