Answer the question
In order to leave comments, you need to log in
Why do we need methods for sending data other than GET, POST?
Why do we need other requests like OPTIONS, PUT, PATCH, DELETE, HEAD, TRACE, CONNECT, if in html forms, js ajax they cannot be sent (and you have to invent bicycles by the type of a hidden field with the value of the name of one of these methods), and in php cannot process them (only if, again, to accept them in post, just check the value of the received variable, say method). And does anyone know if there will be normal support for these methods in the same php and html forms? it’s also interesting what’s the point of using them at all if in the end you can do the same thing with a regular post as without them
Answer the question
In order to leave comments, you need to log in
It is convenient to make endpoints in API
[GET] /order/{id} получить информацию о заказе
[POST] /order/{id} создать новый заказ
[PUT] /order/{id} обновить данные в заказе
[DELETE] /order/{id} удалить заказ
[GET] /order/{id}
[POST] /order/{id}/create
[POST] /order/{id}/update
[POST] /order/{id}/delete
will there be normal support for these methods in the same php and html forms?
php://input
Read the HTTP specification, they describe why such methods are used, etc. In addition to html and php, there are a lot of technologies in which HTTP is used completely.
You can send everything, even any custom methods, thereby violating the specification.
[
'OPTIONS', 'post', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'TRACE', 'CONNECT', 'hui'
].forEach(method => {
try {
const req = new XMLHttpRequest()
req.onload = console.dir
req.open(method, '/')
req.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
req.send(JSON.stringify({
method
}))
} catch (er) {
console.error('disallow', method)
}
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question