Using PUT method in HTML form

后端 未结 7 2039
情话喂你
情话喂你 2020-11-22 11:30

Can I use a PUT method in an HTML form to send data from the form to a server?

相关标签:
7条回答
  • 2020-11-22 12:09

    Can I use "Put" method in html form to send data from HTML Form to server?

    Yes you can, but keep in mind that it will not result in a PUT but a GET request. If you use an invalid value for the method attribute of the <form> tag, the browser will use the default value get.

    HTML forms (up to HTML version 4 (, 5 Draft) and XHTML 1) only support GET and POST as HTTP request methods. A workaround for this is to tunnel other methods through POST by using a hidden form field which is read by the server and the request dispatched accordingly. XHTML 2.0 once planned to support GET, POST, PUT and DELETE for forms, but it's going into XHTML5 of HTML5, which does not plan to support PUT. [update to]

    You can alternatively offer a form, but instead of submitting it, create and fire a XMLHttpRequest using the PUT method with JavaScript.

    0 讨论(0)
提交回复
热议问题