0

This is a working fiddle. http://jsfiddle.net/bpBtC/1/

But this http://jsfiddle.net/bpBtC/131/ doesn't work with the same method?

(All the other websites with XML feeds also fail using the same method, why?)

$(document).ready(function () {
    $.ajax({
        type: "GET",
        url: "http://www.blogger.com/feeds/2399953/posts/default",
        dataType: "xml",
        success: xmlParser,
        dataType: 'jsonp'
    });
});

function xmlParser(xml) { 
    $(xml).find("entry").each(function () {
        $(".entirecont").append($(this).find('title').text());
    });
}
Hasan Alaca
  • 232
  • 2
  • 14

2 Answers2

1

You are setting dataType twice.

$(document).ready(function () {
    $.ajax({
        type: "GET",
        url: "http://www.blogger.com/feeds/2399953/posts/default",
        dataType: "xml",
        success: xmlParser,
        dataType: 'jsonp' //<-- this is what actually used.
    });

Remove the second dataType and your code will fail.http://jsfiddle.net/bpBtC/130/

Yury Tarabanko
  • 44,270
  • 9
  • 84
  • 98
0

The first fiddle works because it is using JSONP (not XML) as the return data type and a method of circumventing the cross-site scripting restrictions. Familiarize yourself with JSONP and how it works.

The second feed does NOT return JSONP, it returns XML and so it can't work. Also you can't have two datatype-parameters on same ajax-call.

Esko
  • 4,109
  • 2
  • 22
  • 37
  • 2
    blogger.com implemented jsonp so this is why it is working, the other sites you tried didn't. – Joucks Nov 05 '13 at 14:41
  • According to Tumblr they have JSONP-enabled api http://www.tumblr.com/docs/en/api/v2 It should work if called right. – Esko Nov 05 '13 at 14:44
  • Modified my answer why the second fiddle does not work. You are not calling the tumblr api correctly to get jsonp result. – Esko Nov 05 '13 at 15:00