Hasan Alaca
Hasan Alaca

Reputation: 232

working XML feed , blogger is an exception?

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());
    });
}

Upvotes: 0

Views: 56

Answers (2)

Esko
Esko

Reputation: 4207

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.

Upvotes: 0

Yury Tarabanko
Yury Tarabanko

Reputation: 45121

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/

Upvotes: 1

Related Questions