0

The action that I want is to change the video to their respective item when keyboard "enter" but it returns me an error "UNDEFINED" has something to do with the plugin I'm using to select items. Another aspect is that the video alone it should not be loaded page (ajax).

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;

    });
    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>');
    });
    $(".container-list-podcast ul li a").click(function () {
        var href = $(this).attr('href');
        alert(href);
        $("#myvideo").attr("src", href).get(0).play();
        return false;
    })
    // Load Navigation Only Key
    a = $('.nav_holder li').keynav(function () {
        return window.keyNavigationDisabled;
    });
});

jsfiddle

  • You are making a cross domain request .. You need to use `jsonp` for such requests.. And use `$.ajax` instead of `$get` to pass in the option – Sushanth -- Aug 10 '13 at 01:24
  • I did not understand, how it will be? I tried to change to `$get` and not charged me anything. – cristiano veloz Aug 10 '13 at 01:54
  • You need to specify `data:"jsonp"` as a property of list of options.. Check http://stackoverflow.com/questions/11736431/make-cross-domain-ajax-jsonp-request-with-jquery – Sushanth -- Aug 10 '13 at 01:58
  • 1
    Alternatively you could also create a "proxy" page on your web server that make a GET call to yahoo and return its response as it was from your domain. – Roger Barreto Aug 10 '13 at 03:51

1 Answers1

1

Since you are using cross domain request you should make sure that the server you connect to support requests like this.

But you also need to tell jQuery to support this request by doing the following:

 $.support.cors = true;

full answer can be seen in jQuery site

Scription
  • 646
  • 3
  • 12
  • 21