user8244016
user8244016

Reputation: 1019

What does ":" in URL mean?

some requirement in my school project asks to send some AJAX request to the server to the url :

http://localhost:8000/messages/:id

where I should set the value of the id as a unique number. I know that ? means a query search and # as mentioned here but what does : mean? and if I set id value to be equal to 123,how it is shown ,like this : http://localhost:8000/messages/:123 or like this:http://localhost:8000/messages/123

I appreciate any help

Upvotes: 5

Views: 1322

Answers (2)

Marco Faustinelli
Marco Faustinelli

Reputation: 4226

The third : in the URL you presented is just a placeholder indicating that id is a variable name. Therefore, :id must be replaced by a value, for example 123.

Your second attempt answer is correct.

Upvotes: 1

Faust
Faust

Reputation: 57

There are two ':' in your url. The first one separates the host from the port e.g. host:port - in your case the host is localhost, the port is 8000.

Second case, ':id', specifies that the id is a variable. It can be replaced by any value such as '123'. The notation is there so you can differentiate a string in the url (../messages/id) from the usage of variables (../messages/:id).

All in all you have to drop the : in usage as you insert a value for the variable.

Upvotes: 2

Related Questions