content:encoded: in JSON with JQuery
content:encoded: in JSON with JQuery
我正在尝试使用JQuery访问以下JSON内容。
http://pipes.yahoo.com/pipes/pipe.run?_id=14756b1d828eae9693f6ef235de879cc&_render=json
我可以访问标题和描述罚款通过使用:
var item_html = '<li><a href="'+item.link+'">'+item.title+'</a></li>'+item.description+'';
但我在访问内容时遇到了问题:编码:因为我尝试时出现语法错误:
var item_html = '<li><a href="'+item.link+'">'+item.title+'</a></li>'+item.content:encoded+'';
我相信有一个简单的解决方案,但我无法绕过它。我试过加引号,因为这对我来说最有意义,但一直没能奏效。
提前谢谢。
您不能直接使用像:
这样的特殊令牌,但可以使用['PropertyName']
访问您的数据
所以把你的代码改成这样;
var item_html = '<li><a href="'+item.link+'">'+item.title+'</a></li>'+item['content:encoded']+'';
下面是演示如何访问您的数据
您不能使用特殊字符的点表示法,您必须使用括号表示法:
更改
item.content:encoded
至
item['content:encoded']
还要注意,在LI之外的UL中不能有文本节点:
'....</a></li>'+item.content:encoded+'';
FIDDLE
相关文章:
- Replacing jQuery.bind with jQuery.on
- PHP $_GET with jQuery $.get call
- Rails 3 if statement with jQuery?
- Trouble with jquery .append
- Javascript setTimeout function with JQuery
- Like Unlike toggle button with jQuery's AJAX
- IE8 issue with jQuery attr()
- ltrim with jQuery?
- json foreach array of arrays with jquery
- Setting Javascript along with JQuery
- XML to HTML with jQuery
- JQuery.animate(): HTML5 annimation with JQuery
- Bootstrap Contact Form with jQuery Validation and AJAX
- HTTP GET request with JQuery
- JavaScript Date with jQuery Countdown
- iframe Fade Out/In with jQuery
- Knockout with jquery.tmlp
- HREF within an IFrame with JQuery
- Coloring tr with jQuery
- ajax post with jquery to mongodb