0

I am overwhelmed, I can't read an external url (http://earthquake.usgs.gov/earthquakes/feed/geojson/1.0/hour) which contains geoJSON string. I attempted using this script:

.ajax({
 type: "GET",
 url: 'http://earthquake.usgs.gov/earthquakes/feed/geojson/1.0/hour',
 dataType: 'json',
 success: function(data) {
 alert(data.features[0].properties.mag);
 } 
 });

I also attempted using the URL plus '&callback=foo' and setting the foo function.

I don't know what to do in order to read this external url. I would like to read an obtain the json string or as text string. Please give me a hand to solve it.

  • 2
    You cannot fetch content from URLs in different domains unless that domain is configured with CORS headers to allow it. That one does not seem to be. – Pointy Apr 05 '13 at 13:44
  • 1
    Javascript has a cross domain policy where you simply can't get data from external sites. Unless they use CORS or support JSONP. This one does'nt seem to support neither. – adeneo Apr 05 '13 at 13:44
  • http://stackoverflow.com/a/15521572/739897 this will help – Narek Apr 05 '13 at 13:49
  • Hello guys, thanx for your reply. Is there any way to do it? Any Ideas? – Billy Edson Apr 05 '13 at 13:50

0 Answers0