从路径加载文本JSON从keypress事件开始

时间:2013-08-14 21:20:33

标签: jquery json

按“输入”时,我需要在每个视频的每个描述中放入标记<p class="description"><p>。 path json是:json.query.results.channel.description

的javascript:

    var main = function () {
        var url = "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=?";

        $.ajax({
            type: 'GET',
            url: url,
            async: false,
            jsonpCallback: 'jsonCallback',
            contentType: "application/json",
            dataType: 'jsonp',
            success: function (json) {
                // titulos
                var titles = json.query.results.channel.item.map(function (item) {
                    return item.title;

                });

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

                });

                $(".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 class="link-podcast" href="' + urls[key] + '">' + text + '</a>');
                });

                // Load KeyNavigation
                a = $('.nav_holder li a').keynav(function () {
                    return window.keyNavigationDisabled;
                });

...

JSFIDDLE AND FULL CODE

0 个答案:

没有答案