1
   $.ajax({
        type: "PUT",(or "DELETE")
        url: "example.com/controller",
        data: {
            ID: 10,
        },
        cache: false,
        success: function(data) {}

    });

here my ajax, and in my controller i want to get ID, but c.PostForm("ID") not work for delete(work for PUT), help me please!

Finally, i have to pass params to URI.(delete method)

Vutuz
  • 458
  • 1
  • 7
  • 19
  • 2
    Where is your go code ? – hlscalon Feb 15 '17 at 11:32
  • https://play.golang.org/p/tOFxziLgGo example here, thanks for reply – Vutuz Feb 15 '17 at 11:40
  • You can find the answer from [If a DELETE request includes an entity body, the body is ignored [...]](https://stackoverflow.com/questions/299628/is-an-entity-body-allowed-for-an-http-delete-request) – luojie Apr 08 '20 at 03:13

1 Answers1

0

It looks like you need to call the ParseForm method first - https://golang.org/pkg/net/http/#Request.ParseForm

joncalhoun
  • 1,498
  • 1
  • 17
  • 22
  • test := c.Request.ParseForm() not work for me, i return nil – Vutuz Feb 16 '17 at 01:42
  • Try accessing the postform params after calling the ParseForm function. I don't use gin myself but that is how the http package works iirc – joncalhoun Feb 16 '17 at 08:16