node.js - Express adding URL to filePath after form submit -


app.js

.... app.get('/index', function(req,res) {   res.render('index', {}); }); app.get('/indexs', function(req,res) {   res.render('index', {}); }); app.get('/indexs/:sistr', function(req,res) {   res.render('index', {}); }); 

jade (pug):

    form(role="form",id="form1",action="",target="tarframe")       ... iframe#tarframe(style="display: none") script(type="text/javascript").   $('#form1').on('submit') function(e) {     ....     window.location.href = '/indexs/'+str;   }); 

the application works fine until /indexs/'some string' called form submit. when page gets rendered scripts/css/etc loaded have url first part of filepath. when /index rendered on initial application load, scripts example:

get /vendor/select2/select2.min.js   (rc=200) 

when /indexs/'some string' called form submit (which renders index), scripts as:

get /indexs/vendor/select2/select2.min.js     (rc=404) 

don't know how fix.

update:

very strange.

if use following in .on('submit') scripts part of index have right filepaths.

window.location.href = '/indexs'; 

if use following scripts have /indexs prepended filepath , not load properly.

window.location.href = '/indexs/'+str; 

even though both app.get(s) render same jade file (index).


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -