Http requests: Put, Delete, and Options

Brandon Comstock
3 min readNov 8, 2019

--

Before getting into telling you what the Put, Delete, and Options methods do, you may ask yourself what is an http request?

Well, http defines a set of request methods to indicate the desired action to be performed for a given resource (a resource being something on a web page, such as a friend on facebook or something like that).

Here is a list of many, if not all, request methods.

We will only be talking about these three however.

Firstly, the Put method replaces all current representations of the target resource with the request payload.

Let’s use an example utilizing ajax.

As you can see, the url is a list of people you have blocked on facebook. And we are using a Put request to update that list, so Johnny is now unfortunately blocked by Elizabeth.

Next, the Delete method just deletes or removes the specified resource. It is pretty self explanatory.

Here is another ajax example.

In this example, we are simply removing Billy from our friends list. Note that there is a success callback function that will fire once the deletion has been done.

Finally, there is the Options method. It is also fairly self explanatory, it is used to describe the communication options for a target resource.

Please look at the final example.

Here we are simply going to get information about what methods there are for the “Find friend” part of facebook, where someone could search for a potential friend.

Here’s a simple review:

PUT updates a resource.

DELETE deletes a resource.

OPTIONS requests information about what methods are supported by the resource.

And there is one small note, unlike the Get and Post methods, there is no built in jQuery method (besides ajax).

Thank you for reading, hopeful you came out of this blog post with a better idea of http requests, specifically Put, Delete, and Options.

--

--