4

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

user8244016
  • 929
  • 3
  • 12
  • 24

2 Answers2

2

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.

Faust
  • 57
  • 1
  • 7
1

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.

Marco Faustinelli
  • 3,734
  • 5
  • 30
  • 49