我的一个学校项目要求将一些AJAX请求发送到服务器的url:
http://localhost:8000/messages/:id
在这里,我应该将id的值设置为唯一数字。我知道?表示查询搜索,#正如这里提到的,但是:是什么意思? 如果我将id值设置为等于123,它的显示方式是这个 http://localhost:8000/messages/:123 ,还是 http://localhost:8000/messages/123?
任何帮助都将不胜感激!
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.
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.