0

I need to load an xml feed from vimeo, for this I am using jquery like this:

$(function(){

// Get vimeo feed
$.ajax({
    type: "GET",
    url: "http://vimeo.com/api/v2/<my username>/videos.xml",
    dataType: "xml",
    success: function( xml ) {
        $(xml).find( "video" ).each( function() {
            console.log( $(this).find( "title" ) );
        });
    }
});

});

But I get this error: XMLHttpRequest cannot load http://vimeo.com/api/v2//videos.xml. Origin http://localhost:8888 is not allowed by Access-Control-Allow-Origin.

I am using MAMP if that makes any difference.

1

1 Answer 1

1

Please read the vimeo API - User

Making the URL

http://vimeo.com/api/v2/username/request.output
username Either the shortcut URL or ID of the user, an email address will NOT work.
request The data you want. The different request types are listed below.
output Specify the output type. We currently offer JSON, PHP and XML formats.

So instead of making a request like http://vimeo.com/api/v2//videos.xml make a request like http://vimeo.com/api/v2//videos.json

Now you can use $.getJSON to get the results like this.

$(document).ready(function() {
    var url = "http://vimeo.com/api/v2/{username}/videos.json?callback=?";
    $.getJSON(url, function(data) {
        var items = [];
        $.each(data, function(key, datum) {
            items.push("<ul>");
            items.push("<li>Title: " + datum.title + "</li>");
            items.push("<li>Tags: " + datum.tags + "</li>");
            items.push("</ul>");
        });
        $("#result").html(items.join(""));
    });
});

View Demo: http://jsfiddle.net/naveen/Ssdjp/1/

Sign up to request clarification or add additional context in comments.

1 Comment

thanks a lot for the code snippet works like a charm, I was just reading about the JSON bits

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.