I cannot figure out what I'm doing wrong with this. It worked for me on another page but it doesn't work for this page (capitalbikeshare). The 'data' variable does contain an object but when I try to print out the length or a specific item it gives me an error msg saying that it cannot read property of null 'feed'. What am I doing wrong?
$.ajax({
url:'http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=10&callback=?&q=' + encodeURIComponent('https://www.capitalbikeshare.com/data/stations/bikeStations.xml'),
dataType : 'jsonp',
success: function (data) {
var entry = data.responseData.feed.entries;
var entry_length = entry.length;
alert("success"+entry_length);
},
error: function(jqXHR, textStatus, errorThrown) {
alert("fail");
}
});
Here is a small sample of the XML file.
<stations lastUpdate="1447107709602" version="2.0">
<script id="tinyhippos-injected"/>
<station>
<id>1</id>
<name>20th & Bell St</name>
<terminalName>31000</terminalName>
<lastCommWithServer>1447107692939</lastCommWithServer>
<lat>38.8561</lat>
<long>-77.0512</long>
<installed>true</installed>
<locked>false</locked>
<installDate>0</installDate>
<removalDate/>
<temporary>false</temporary>
<public>true</public>
<nbBikes>5</nbBikes>
<nbEmptyDocks>5</nbEmptyDocks>
<latestUpdateTime>1447106879008</latestUpdateTime>
</station>
</stations>
dataobject?{"responseData": null, "responseDetails": "bad or missing callback or context", "responseStatus": 400}{"responseData": null, "responseDetails": "Feed could not be loaded.", "responseStatus": 400}