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 badges
Add a ment  | 

1 Answer 1

Reset to default 9 +50

I'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