1

I'm using the following jQuery code to try and access the delicious api, but it's not working. If I go directly to the api url in the browser it returns the xml as expected, so the url is correct.

Anyone got any ideas what's up? Could be that it's https, but teh jQuery documentation doesn't explicitly forbid this.

$(document).ready(function(){
    $.ajax({
        type: 'GET',
        dataType: 'xml',
        url:"https://api.del.icio.us/v1/posts/dates",
        success: function(response) {
            console.log(response);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            console.log(textStatus);
            console.log(errorThrown);
        }
    });
});

edit:

I get a "data is null" error, which still happens if I set data: '', and on first attempt to access the page in the browser I'm prompted for username and password, which seems to be stored as if I include a tag with href="https://api.del.icio.us/v1/posts/dates" in the head it downloads the file ok

wheresrhys
  • 22,558
  • 19
  • 94
  • 162
  • More detail please: what do you mean by "it's not working"? Edit: When I paste that URL into my browser, I am prompted for a username and password. – Matt Ball Feb 11 '10 at 15:22
  • 3
    My first thought is that it's a cross-domain security issue - you can't issue XHRs to a different domain than your code is sitting on. JSONP APIs get around this issue, but it doesn't appear that delicious offers one of those. – Rufo Sanchez Feb 11 '10 at 15:24
  • @Rufo> good point, the API shows every example using cURL. – bdl Feb 11 '10 at 15:28

1 Answers1

1

As Mr. Sanchez points out, you can't issue XMLHttpRequests to that API from a page hosted in your domain.

Maybe they've got a JSONP version of the API.

Read this: Get Delicious API URL Tags/Bookmarks via jQuery

skozz
  • 2,662
  • 3
  • 26
  • 37
Pointy
  • 405,095
  • 59
  • 585
  • 614
  • delicious have been pretty lazy as you can get the feeds - up to 100 latest items - via json, but not the full API. I can't imnagine it woudl be more than a few days (hours? minutes?) work for them to create json templates in addition to the xml. Thanks for the answer though – wheresrhys Feb 11 '10 at 15:37
  • URL not found. http://blogs.burnsidedigital.com/2009/03/get-delicious-api-url-tagsbookmarks-via-jquery/ – skozz Feb 11 '14 at 17:44