The problem is I render a view and send some data
console.log(products); // shows an array
res.render('seller/sell',{'shop_id':req.user.shop_id ,'products':products});
and I save the data like this in jade
input(id='shop_id',type='hidden',name='shop_id',value='#{shop_id}')
input(id='pd',type='hidden',name='pd',value='#{products}')
if(products !='')
each val , key in products
a(href!='home/sell/edit?id=#{val.id} ',class='product')
img(class='product_thum',src!='#{ val.product_thum}',alt!='#{ val.product_name}',title!='#{ val.product_name}')
p.product_name #{ val.product_name}
and then I try to get the products
var d = $('#pd').val();
console.log(typeof d); //shows string
I know that products shuld be a array otherwise
if(products !='')
each val , key in products
a(href!='home/sell/edit?id=#{val.id} ',class='product')
img(class='product_thum',src!='#{ val.product_thum}',alt!='#{ val.product_name}',title!='#{ val.product_name}')
p.product_name #{ val.product_name}
Wont work, but why did I get a string when I need the array?
What did I do wrong?