0

I am trying to obtain a list of assets (via JSON) inside of a drop using a free drop.io account.

Note that I have already looked at the other two questions (question1 and question2) concerning this and neither of them provided a solution.

    var dropName = escape("greganddonny");
            var apiKey = "some key I'm not displaying it here...";
            var version = "2.0";

    var assetsListBaseURL = "http://api.drop.io/drops/greganddonny/assets.json?api_key=" + apiKey + "&version=" + version;

    var resultingdata = null;

    function getFileList() {
        console.log("BEGIN: getFileList()");
        var surl = assetsListBaseURL + '&callback=?';

        $.getJSON(surl, function(data, textStatus) {
            console.log("textStatus:" + textStatus);
            console.log("BEGIN: Callback()");
            resultingdata = data;
            showResult();
            console.log("END: Callback()"); 
    });

        console.log("END: getFileList()");
    }

    function showResult()
    {
        alert(resultingdata);
    }

    $(document).ready(function() {
        console.log("BEGIN: document.ready");
            $.ajaxSetup({
            "error": function(XMLHttpRequest,textStatus, errorThrown) {   
              alert(textStatus);
              alert(errorThrown);
              alert(XMLHttpRequest.responseText);
              }
            })

            $("#search").click(function() {getFileList();});
        console.log("END: document.ready");
    });

When the search button on the page is clicked this triggers the getFileList() function. According to my firebug console the getFileList() function is called just fine.

The JSON request is also made successfully as the firebug console's Net tab displays a 200OK status when I call assets.json on drop.io's site. I also receive the following return JSON in the list of requests in the "Net" tab:

    [{"converted":"http:\/\/drop.io\/download\/public\/x0yfnmzdtet1vtxesqcm\/12a9ebc74c9a3e4e3b2e2b4ea3546b919a2519ff\/df43d2b0-926f-012c-26c2-fbe072d62af6\/2a0a5270-9270-012c-8fc9-fbfd417303a8\/v2\/content","type":"audio","status":"converted","title":"MikeAndAndyOnPhone2009.MP3","duration":118,"artist":"Unknown","created_at":"2009/10/03 17:29:02 +0000","filesize":1895424,"description":null,"track_title":"Unknown","hidden_url":"http:\/\/drop.io\/hidden\/sazpcf7522exzb\/asset\/bWlrZWFuZGFuZHlvbnBob25lMjAwOS1tcDM=","name":"mikeandandyonphone2009-mp3"}]

I validated the above block of returned JSON using JSONLint and it reports that the JSON returned is indeed valid, you can test this out by copying and pasting the block above.

I've tried everything I know how to try, I've even added an "error" option to the $.ajaxSetup method and I still haven't had any success returning even an error message as to why my callback function is not being called.

Any idea why this might be? You can test out my script here

1
  • Additionally let me state that this is hosted on an Apache 1.3 really old Linux server and I was just wondering if that might effect it.
    – leeand00
    Oct 14, 2009 at 15:33

1 Answer 1

2

JSONP requires the server to support JSONP requests. However if you visit

http://api.drop.io/drops/greganddonny/assets.json?api_key=API_KEY_HERE&version=2.0&callback=x

the document returned looks like [{"converted..) although it should look like x([{"converted"..) because of the x callback.

Apparently drop.io doesn't support JSONP (documentation doesn't tell so either). The only option that's left for you is the classic approach to cross-domain js: Use a Proxy.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.