I am working on a home page that displays text posts as part of a large project when the user Sends a GET request for / home page
res.render ('home', {user: req.ping_session, posts: p_l});
p_l is an array back from my mongoDB database.
The problem is that I am trying to update the list of posts without reloading the page and I do not know how to update the post, Do not even save as a global variable. Is there a way to update the list of posts? I had thought about doing this through thought, but I do not think it is really necessary.
I am quite new to the node, so I really appreciate some help from you.
Thanks in advance!
Post-text "itemprop =" Text ">
There is no way to reload the post without reloading the page in your current state.
The way your app works currently, that's it An HTTP request is received, the processes come out, and then some data (render) is exited from the browser, then that connection has ended. There is no way to communicate with the rougeer unless he opens a new request with you, in that case you will not have any way to associate the first request with the other (except the IP address)
< P> You can search for websites (I recommend for nodes) which is a different type of connection from a regular HTTP request where browsers and servers maintain a connection and pass a request. Rather than blocking, messages back and forth.Many sites use the website for such things. They will often use a mixer, for example, when you are on stack overflow You make a web request that refers to the page you are viewing, but SE also maintains a websocket for small incidents like 'O user has a new information in your inbox'. In your case, you can trigger an incident that tells the client, 'hey, a new post from your user is waiting for it' Once you receive it, you can post AJAX (A method of creating regular HTTP requests from the browser).
Hope this gives you some direction.
No comments:
Post a Comment