javascript - using value from script in jade template -


i'm new in jade, , have came cross trouble that, have such script code in jade template

script.      function processinfo() {         $.ajax({             url: '/dataloader/scheduler/proccesinfo/' + #{project.id},             type: "post",             data: null,             cache: false         }).done(function (msg) {             if  ($.trim(msg)) {                 //$("#processinfopanel").html(msg);                 var = msg;                 console.log(a);             }         }).fail(function (jqxhr, textstatus) {             console.error("request failed: " + textstatus);         });     } 

i have value of a variable in jade template above

 tr             th processes             td                 h3= #{a}                      case #{a}                         when '': span.label.label-warning none                         when null: span.label.label-warning none                         default: span#processinfopanel.label.label-success 

i have used it's incorrect syntax(((( how can it? thanks!

this depends on whether writing client side or server side javascript.

from can tell writing client-side.. in case #{ } less applicable. standard dom - manipulation may best approach here...

var h3 = document.getelementsbytagname('h3'); h3.innerhtml = 

since ajax call though, may need return a in object literal notation.

response {variableofchoice: a} #{variableofchoice}

this straight javascript, applying same method in jquery syntax should work.


Comments