Mootools JSON(拉动顶级项目)
尝试从我的 json 请求中提取所有“标题”,但没有成功。
当前 Fiddle = http://jsfiddle.net/DZkZV/
当前 Json:
{
"title": "Title 1"
},
{
"title": "Title 2"
},
{
"title": "Title 3"
},
{
"title": "Title 4"
}
当前JavaScript:
var addTopTopItemsLi = function(title){
title.each(function(){
var el = new Element('li'),
htmltxt = new Element('span', {'class': 'pgTitle','html': title.title}).inject(name);
inject(gallery);
});
};
Trying to pull all "titles" from my json request, with no success.
Current Fiddle = http://jsfiddle.net/DZkZV/
Current Json:
{
"title": "Title 1"
},
{
"title": "Title 2"
},
{
"title": "Title 3"
},
{
"title": "Title 4"
}
Current Javascript:
var addTopTopItemsLi = function(title){
title.each(function(){
var el = new Element('li'),
htmltxt = new Element('span', {'class': 'pgTitle','html': title.title}).inject(name);
inject(gallery);
});
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你现在有点操之过急了,不是吗:)
http://jsfiddle.net/ dimitar/DZkZV/1/
点:
- json 需要是一个项目数组。
- 你必须传递整个响应然后循环它。
- .each 循环中的异常和不一致的引用。
ps 新的 firebug 1.8.3 太差了,无法显示 ajax 后的内部异常,太令人沮丧了......
you are jumping the gun a little bit now, aren't you :)
http://jsfiddle.net/dimitar/DZkZV/1/
points:
- json needed to be an array of items.
- you have to pass on the whole response and then loop it.
- exceptions in the .each loop and inconsistent references.
p.s. the new firebug 1.8.3 is so poor it failed to show the inner exceptions after the ajax, so frustrating...