【问题标题】:Angular JS `$http` sends POST instead of GETAngularjs `$http` 发送 POST 而不是 GET
【发布时间】:2015-06-02 04:32:06
【问题描述】:

这段代码,

$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)

我该如何解决这个问题?

【问题讨论】:

    标签: javascript angularjs jsonp angularjs-http


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2017-08-09
      • 2012-03-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-20
      • 1970-01-01
      相关资源
      最近更新 更多