Such as topic ~ ~ ~ ~ ~ ~ ~
This is because browsing is restricted by security policies. Without processing, client ajax requests for data from other domains are prohibited.
Of course, you can put the data under the same domain name of the project, which depends on the project. However, the slightly larger projects are all restful structures. The API requesting data is made into a general interface and placed under other domains for calling. Except that Project A can use its interface with Project B and Project C, this is one of the benefits.
Secondly, every url request in this domain carries cookie information, which increases the amount of data transferred and the burden on the server (which is one of the reasons why static resources are placed under other domain names). In addition, cookies are stateful and carry sessionID and other states, while restful API is stateless, which means that authentication of user requests is independent of cookies and session.
Finally, in order to understand this answer, you have to search for what restful is.