I have a webservice returning jsonp format. here’s the code:
$(document).ready(function(){
$.getJSON("http://api.tubeupdates.com/?method=get.status&lines=central,victoria&return=name&jsonp=?",
function (result){
$.each(result.items, function(item){
$('body').append(item.response.lines[0].name);
});
}
);
});
It works fine if I remove the loop but fails with the $.each loop.
Any idea of what am I doing wrong?
Thanks
Mauro
The response doesn’t have an array on an
itemsproperty, it looks like this:It looks like you want to iterate the
response.linesarray, in which case you need to do this:You can test it out here.