Darshan
Darshan

Reputation: 2379

JSON url parsing issue with jquery

I have a requirement to parse iTunes url and display data. I have an issue when I'm parsing, can anyone who knows how to do it, parse below url in jQuery ajax or js?

I have tried a lot but getting error undefined.

function onDeviceReady() {
    // Now safe to use device APIs
    var flickerAPI = "https://itunes.apple.com/in/rss/topalbums/limit=10/json";
    $.getJSON(flickerAPI, { format: "json" })
        .done(function(data) {
            $('#your-tweet').append('<li>'+data);
        });
}

Upvotes: 0

Views: 218

Answers (5)

user859952
user859952

Reputation:

You can get all name list with below code .

for(i=0;i<=10;i++) 

    { 

         var d1 = data.feed.entry[i]["im:name"].label;

        alert(d1)

    }

Upvotes: 1

Darshan
Darshan

Reputation: 2379

Thanks all to for reply

Here i have done with below code .

(function(){

var flickerAPI = "https://itunes.apple.com/in/rss/topalbums/limit=10/json";

$.getJSON(flickerAPI, { format: "json" })

.done(function(data)

{

for(i=0;i<=10;i++) { var d1 = data.feed.entry[i]["im:name"].label

$('#your-tweet').append('

  • '+JSON.stringify(d1));

    }

    }); }())

    http://jsbin.com/seyuwele/1/edit

    Upvotes: 0

  • Jeetendra Chauhan
    Jeetendra Chauhan

    Reputation: 1977

    (function(){
      var flickerAPI = "https://itunes.apple.com/in/rss/topalbums/limit=10/json";
        $.getJSON(flickerAPI, { format: "json" })
            .done(function(data) {
             var d1 = data.feed.entry[0]["im:name"].label
             console.log(data)
             $('#your-tweet').append('<li>'+JSON.stringify(d1));
        });
    

    }())

    DEMO

    Upvotes: 1

    Brij Raj Singh - MSFT
    Brij Raj Singh - MSFT

    Reputation: 5113

    flickerAPI = "https://itunes.apple.com/in/rss/topalbums/limit=10/json"; 
    $.getJSON(flickerAPI,{ format: "json" }).done(function(data) 
    {
        alert(data.feed.entry[0]["im:name"].label);
    });
    

    The fiddle is at http://jsfiddle.net/YGbx7/1/

    Upvotes: 3

    wrivas
    wrivas

    Reputation: 509

    Try using the correct way:

    var URL = 'PATH_TO_YOUR_SERVER';
    
    $.get(URL, {}, function(response){
        // Here 'response' is the JSON response
    
    },'json'); // Tells to jQuery that the response is a JSON
    

    Upvotes: 0

    Related Questions