Angular JS` $ http`发送POST而不是GET

时间:2015-03-29 01:09:23

标签: javascript angularjs jsonp angularjs-http

此代码,

$http.jsonp('http://localhost:3000/students?callback=JSON_CALLBACK',{
                data:student,
                method:'POST'
})

发送GET请求而不是POST请求。 Rails日志:

Started GET "/students?callback=angular.callbacks._1" for ::1 at 2015-03-28 
20:07:30 -0500
Processing by StudentsController#index as */*
  Parameters: {"callback"=>"angular.callbacks._1"}
  Student Load (0.5ms)  SELECT `students`.* FROM `students`
  Rendered students/index.jpbuilder (2.4ms)
Completed 200 OK in 7ms (Views: 5.9ms | ActiveRecord: 0.5ms)

我该如何解决?

1 个答案:

答案 0 :(得分:4)

JSONP次请求只能是GET次请求。我会看一下this帖子,详细说明为什么这是不可能的。

相关问题