ajax - Trouble parsing JSON feed from REST API call with jQuery -


i have rest api endpoint i'm trying parse using $.ajax call. can see json structure endpoint url, can't access key:value pairs. how can access "live" "type" , "items" "sections"? there not cross domain issue in case holding me back. code:

<div>     <p class="type">type:</p>     <p class="id">id</p> </div>  $(document).ready(function () {     $.ajax({         url: "http://myrestapiurl.com/"     }).then(function (data) {         $('.type').append(data.type);         $('.id').append(data.items.id);     }); }); 

json response:

{ status: {     code: 200 }, entity: {     sections: [{         type: "live",         items: [{}, {}, {}, {}, {}, {}],         entitytype: "section"     }],     entitytype: "content"     } } 

there no data.items.id in json specified , though , can access data first :

     var itemsarray = entity.sections[0].items ; 

now , if there id field in items ( in each object ) can :

    var itemsarray = entity.sections[0].items[0].id ; // 0 first object in items 

Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -