Is there any way to submit a javascript variable to the server-side using jade form?

82 Views Asked by At
        form(role='form', action='/logout', method='POST')
          button.btn.btn-warning.btn-lg(type='submit') Log Out
          input(name='newList', type='hidden', value= locals.usr )
        p
          script(type="text/javascript").
            usr= new Usr();
            usr.setName("#{user.username}");
            var tk;
            if ('!{tasksTD}'!=''){tk = JSON.parse('!{tasksTD}'); usr.setToDo(tk);}
            if ('!{tasksD}'!=''){tk = JSON.parse('!{tasksD}'); usr.setDone(tk);}
            usr.setDone(tk);
            usr.write();

I render this jade document from the server side (express js) like res.render('home',{user:.., tasksTD:.., tasksD:...}) then I use a script to modify that data (using a few js files with enyos kinds and stuff, dont think that really matters, there i have made the definitions of kind Usr, setToDo, setDone). To the point.. Let´s say I want to return the variable usr when I submit, (make a form with value=usr or something like it) to use it on the server side.. is there any way to do it? I know it lacks sense a little bit, but I need to make it somewhat like this.

0

There are 0 best solutions below