0

I would like to appear within the tag <p> the description of the selected item in the menu, but I'm back with an error all the html. Anyone know what property should I use?

The path json is: data.query.results.channel.item.description

javascript:

$.getJSON("http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%3D'http%3A%2F%2Frss.cnn.com%2Fservices%2Fpodcasting%2Fac360%2Frss.xml'%20AND%20itemPath%3D%22%2F%2Fchannel%22&format=json&diagnostics=true&callback=?", function (data) {

    // Load Titles patch Json
    console.log(data.query.results.channel.item);
    var titles = data.query.results.channel.item.map(function(item) {
    return item.title;

    });
    var urls = data.query.results.channel.item.map(function(item) {
        return item.origLink;

    });

    var descri = data.query.results.channel.item.map(function(item) {
        return item.description;

    });

     $(".description-podcast p").text(descri);

    console.log(titles);
    $(".container-list-podcast ul").append('<li>' + titles.join('</li><li>'));
    $(".container-list-podcast ul li").each(function(key, value){
        var text = $(this).text();
        $(this).html('<a href="' + urls[key] + '">' + text + '</a>');
    });
    // Load Navigation Only Key
        a=$('.nav_holder li a').keynav(function() {
            return window.keyNavigationDisabled;
        });
});

jsfiddle

4

3 回答 3

0
         $(".description-podcast p").html(descri);

http://jsfiddle.net/Cf5QU/8/

每个的说明

    var i=0;
    $("a").each(function(){if($(this).css("background")=="blue")i=$(this).index();});

    $(".description-podcast p").html(descri[i]);

http://jsfiddle.net/Cf5QU/9/

于 2013-08-11T13:51:27.007 回答
0

这可能是由于服务器错误(HTTP 代码!= 200)而发生的。

你可能想要:

$.getJSON( 
   "[your code]"
).error(function(e, xhr, settings) {
    console.log(e, xhr, settings);
});
于 2013-08-11T13:54:55.120 回答
0

正确$(".description-podcast p").text(descri);$(".description-podcast p").html(descri);

.text方法会转义任何 html 字符,但.html不会。

于 2013-08-11T14:01:10.863 回答