Origin null is not allowed by Access-Control-Allow-Origin

Posted by JIGGABITS on Stack Overflow See other posts from Stack Overflow or by JIGGABITS
Published on 2012-06-02T20:52:41Z Indexed on 2012/06/03 10:40 UTC
Read the original article Hit count: 345

Filed under:
|

I'm currently working with the SoundCloud API and would like to have a track embed when a button is clicked.

I get two errors:

XMLHttpRequest cannot load http://soundcloud.com/oembed.json?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F48419073. Origin null is not allowed by Access-Control-Allow-Origin.

AND

Uncaught TypeError: Cannot read property 'html' of null

Here is my code:

<button onclick="getPopular()">+1</button>
<div id="track"></div>

<script src="http://connect.soundcloud.com/sdk.js" type="text/JavaScript"></script>
<script type="text/JavaScript">
    SC.initialize({
        client_id: "**************",
    });

    var getPopular = function() {
        SC.get("/tracks", {limit: 1}, function(tracks) {
            var track = tracks[0];
            alert("Latest track: " + track.title);
            SC.oEmbed(track.uri, document.getElementById("track"));
            });
        };
</script>

I use an alert in my code to let me know that it is actually taking information from the SoundCloud API. I'm just not sure what else is preventing it from embedding.

Thanks, ahead of time, or looking at my question.

  • jiggabits

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about soundcloud