I am trying to get a simple PUT and DELETE request to work via JQuery but I get 405. I am new to JQuery, rather learning it.
I am creating two HTML files and deploying it in tomcat 8.5 and running them via localhost.
index.html
<html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content= "width=device-width, initial-scale=1.0"> <!-- Importing the jQuery --> <script src= "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"> </script> </head> <script> function makePUTrequest() { $.ajax({ url: 'test.html', type: 'PUT', success: function (result) { // Do something with the result } }); } function makeDELETErequest() { $.ajax({ url: 'test.html', type: 'DELETE', success: function (result) { // Do something with the result } }); } </script> <body> <button onclick="makePUTrequest()"> Click for PUT request </button> <button onclick="makeDELETErequest()"> Click for DELETE request </button> </body> </html>
And another file test.html
with just simple text GEEKSFORGEEKS.
Simply following the page --> https://www.geeksforgeeks.org/how-to-send-a-put-delete-request-in-jquery/
But I get
405 - method not allowed
one the button click.
Please suggest.