admin管理员组文章数量:1303345
I'm using express js for the REST interface of my application, on node js.
I'm also using jQuery Mobile for my client side pages.
I'm using redirect to change pages if the user tried to enter a location they're not allowed or can't access.
For some reason the url doesn't change, and as a result it doesn't load the css and js files.
I read in another place hat this is happening because of jQuery Mobile and they suggested to use rel=external
.
I don't know how to use it together with the express interface.
Any suggestions to ments on my problem?
I'm using express js for the REST interface of my application, on node js.
I'm also using jQuery Mobile for my client side pages.
I'm using redirect to change pages if the user tried to enter a location they're not allowed or can't access.
For some reason the url doesn't change, and as a result it doesn't load the css and js files.
I read in another place hat this is happening because of jQuery Mobile and they suggested to use rel=external
.
I don't know how to use it together with the express interface.
Any suggestions to ments on my problem?
Share Improve this question asked Sep 1, 2014 at 20:01 David TzoorDavid Tzoor 1,0775 gold badges19 silver badges34 bronze badges1 Answer
Reset to default 9 +50I'm guessing you're sending a POST request and trying to redirect server-side, like so:
app.post('/location', function(req, res) {
if (!allowed) {
res.redirect('/otherpage');
} else {
// do stuff
}
});
You can't redirect to another page on a POST request. But you can send a redirect location with res.send({ redirect: '/otherpage' })
, and then have the frontend do the work, something like:
if (res.redirect) {
document.location.href = res.redirect;
}
本文标签: javascriptExpress js redirectdoesn39t change url and doesn39t load static filesStack Overflow
版权声明:本文标题:javascript - Express js redirect - doesn't change url and doesn't load static files - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741726467a2394643.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论