我想从MongoDB传递一个对象数组到客户端...
这是对象。
在一些个人资料中,可能会有许多图像,因此会有像这样的对象数组。
这是服务器代码。
"datosRecibidos是来自mongodb的对象数组,我正在尝试在jade中放入一个变量。"
但是当我尝试获取这些对象时
控制台日志打印未定义。 为什么会这样???我该如何在客户端正确地从数据库获取信息?? 谢谢大家。
这是对象。
var objeto_img=
{
name:'name of the file',
image:'image.jpg url',
title:'title of the image',
caption:'descripcion of the image',
link:"#",
};
在一些个人资料中,可能会有许多图像,因此会有像这样的对象数组。
[var objeto_img=
{
name:'name of the file',
image:'image.jpg url',
title:'title of the image',
caption:'descripcion of the image',
link:"#",
},var objeto_img=
{
name:'name of the file',
image:'image.jpg url',
title:'title of the image',
caption:'descripcion of the image',
link:"#",
},var objeto_img=
{
name:'name of the file',
image:'image.jpg url',
title:'title of the image',
caption:'descripcion of the image',
link:"#",
};]
这是服务器代码。
res.render('index/perfil_publicacion_contenido',
{
datos:datosRecibidos
})
"datosRecibidos是来自mongodb的对象数组,我正在尝试在jade中放入一个变量。"
input(type='hidden',id='imagenes',value=datos.img)
但是当我尝试获取这些对象时
var fotos=$('#imagenes1').val();
for(foto in fotos)
{
console.log(fotos[foto].image)
console.log(fotos[foto].name)
console.log(fotos[foto].caption)
console.log(fotos[foto].title)
}
控制台日志打印未定义。 为什么会这样???我该如何在客户端正确地从数据库获取信息?? 谢谢大家。