javascript - Doing a DELETE request from <a> tag without constructing forms? -
To delete the request when clicked Form & gt; & lt; A href & gt; Is there a way to implement
regularly GET
? Instead of dynamically & lt;
is to generate the tag that adds the appropriate parameters so that it reaches the right place, but I am not so much interested in dome manipulation for such a simple task.
I thought about the path of something like this: Click
$ ("a.delete") (function () {var do_refresh = false; $ .ajax ({Type: "delete", url: "my / path / to / delete", success: function () {do_refresh = true;}, failure: function () {warning ("there is an error")}}) ; Return do_refresh; // If this is incorrect, then there will not be any freshness. If it is // true then it will need to refresh one page.});
I'm not sure the above AJAX stuff will work because it's just theoretical. Is there any way to go about this?
Note:
Please do not recommend that I use rail : method = & gt; : Remove
link_to
, because I am trying to stay away from the use of rail assistants in many senses because they contaminate my dame with intrusion javascript. I should put this solution into an external JS file and should be included as needed.
According to the docs:
DELETE method Is allowed but not supported on all browsers, so you should take a look here:
Comments
Post a Comment