Is there a way to send a DELETE request from a website, using xmlhttprequest
or something similar?
相关问题
- Angular RxJS mergeMap types
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
You can test if your browse has DELETE implemented here
Supposing req is a XMLHttpRequest object, the code would be
req.open("DELETE", uri, false)
;This can be done with
jQuery
, if you don't mind the dependence on a framework. I believejQuery
usesXmlHttpRequest
to perform this action. You'd use the$.ajax
function with thetype
parameter set toDELETE
.Please note that not all browsers support HTTP DELETE requests.
I believe that both PUT and DELETE are not implemented (in the case of Prototype) due to flaky browser support.
As someone mentioned above, jQuery will do this for you, via the following syntax:
You can use php to do this:
setup your XMLHTTPRequst to call a phpscript that deletes a named file, and then pass the filename that you intend to be removed to the php script and let it do its business.
I use fetch API on one of the projects:
I have
deleteEndpoint
,id
andtoken
previously defined.