I am trying to create a one-page application with backbone.js on the front side and node.js / express as a server, I want to have a basic HTML file for the root, and then when the user goes to any path, such as
mydomain.com/foo/bar
I want to be able to handle this path on the client side using javascript instead of making a trip back to the server. I read about backbone routing and click state of HTML5. In this article, he describes the state of depression, for example,
In fact, PushState is actually nothing more than a standard JavaScript API that allows us to manipulate the browser history by “pushing” the full URLs into the browser URL, without back-and-forth to the server and without responding to changes in the URL with Javascript - all without the use of URL hash fragments.
but when I use push state, it actually makes a server request and expects the server to deliver content to / foo / bar. I do not understand how I can avoid this.
Now suppose that even with the click of a button, your client will make a request to the server under mydomain.com/foo/bar when directly visiting this URL. In this case, since I serve the default HTML file, and this HTML file by default has script links in it:
<script type="text/javascript" src="/scripts/myscript.js" ></script>
HTML , /foo root, /foo, , , . ?
. , URL- . . , : : # URL