LDK
LDK

Reputation: 2575

PUT request turns into GET?

A form in my app has the following:

<form  action="/faculty/update/agxzdGFuZHJld3NqaHNyDQsSB0ZhY3VsdHkYBww" method="PUT" accept-charset="utf-8">

However, upon submission the request is treated as a GET and is handled by def get() and not def put(). Any help would be appreciated!

Edit: Thanks for the responses. If I can't use method="PUT" what is the best way of directed the form the the put() method within my handler class? Should I add another handler within main.py?

Upvotes: 0

Views: 757

Answers (3)

Daniel Vassallo
Daniel Vassallo

Reputation: 344311

HTML v4 and XHTML v1 only support the GET and POST request methods within HTML forms.

On the other hand the GET, POST, PUT and DELETE methods are supported via XMLHttpRequest in all modern browsers.

Related Stack Overflow post:


EDIT:

Further to your update, I think your only options would be:

  • Use the POST method in your form and handle it through the post() handler.
  • Use AJAX (XMLHttpRequest) to post your form with JavaScript, using the PUT method.
  • Use HTML5, but this will not work in Internet Explorer.

Upvotes: 6

marklai
marklai

Reputation: 2040

Browsers only do GET & POST methods. See if your app's platform can simulate PUT methods via a "method" parameter.

Upvotes: 2

mythz
mythz

Reputation: 143319

I believe GET and POST are the only valid values on a FORM method attribute.

Upvotes: 1

Related Questions