ExpressJS更改路由而不刷新 [英] ExpressJS change route without refresh
问题描述
嘿,我有一个运行 Express.js 和 Handlebars 的网站,该网站的导航栏和侧边栏在所有页面上都保持不变.当我路由时,它只会更改{{{body}}}
的页面容器.
Hey I have a website run with Express.js and Handlebars that has a navbar and sidebar that stays the same for all the pages. When I route it only changes the page container which is {{{body}}}
.
有没有一种方法可以直接加载路线内容,而无需页面实际刷新和重新加载导航栏和侧边栏?
Is there a way I can just load the content of the routes without the page actually refreshing and reloading the nav and sidebar?
我目前正在使用它进行路由.
I'm currently using this for routing.
router.get('/', checkAuthentication, function(req, res){
res.render('index');
});
任何帮助都会很好,因为我对node还是很陌生.
Any help would be nice as I'm quite new with node.
我只希望容器加载而不是整个网址/页面
I want only the container to load not the whole url/page
推荐答案
谢谢大家考虑/查看这篇文章,我得出的结论是使用 PJAX 来做到这一点.
Thank you all for considering/looking at the post, i have come to the conclusion to be using PJAX to do this.
The tutorial i read, for anyone wondering is : Pjax Tutorial
这篇关于ExpressJS更改路由而不刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!