[英]rails - angularjs sends http.get as html format request
我有这段angularjs代码
$http.get(sprintf("/posts/%s", post.id)).
success(function(data, status, headers, config) {
$scope.post = data;
})
我期望在后端(rails)中获得json格式的请求
respond_to do |format|
format.html
format.json { render json: @post}
end
但是我收到了html格式请求。
我缺少什么? 谢谢你的帮助。
最简单的方法是:
$http.get(sprintf("/posts/%s.json", post.id)).
success(function(data, status, headers, config) {
$scope.post = data;
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.