0

EDIT:Here is the error message: XMLHttpRequest cannot load http://www.geocodefarm.com/api/forward/json/xxxxxxxxxxxxapicodexxxxxxxxxxxxx/london. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'localhost' is therefore not allowed access.

Then this is the code which I am using to try and display the latitude value from the JSON:

$.getJSON("http://www.geocodefarm.com/api/forward/json/d4abb1b19adb13e42eac5a7beac6f4dbeb4b4ba4/" + searchBox.value, function(data) {
    alert("test");
    alert(data.geocodingResults.COORDINATES.latitude);   
});
  • It is `geocoding_results` not `geocodingResults` – vimal1083 Jul 30 '14 at 12:55
  • What does it say if you look at your JavaScript error console? – Quentin Jul 30 '14 at 13:06
  • @Quentin There are errors but the page reloads too quickly and I cannot see them. – user3887741 Jul 30 '14 at 13:09
  • Change your preferences to preserve the console when a new page is loaded then. – Quentin Jul 30 '14 at 13:10
  • Here is the error message: XMLHttpRequest cannot load http://www.geocodefarm.com/api/forward/json/xxxxxxxxxxxxapicodexxxxxxxxxxxxx/london. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access. – user3887741 Jul 30 '14 at 13:22
  • https://duckduckgo.com/?q=site%3Astackoverflow.com+No+%27Access-Control-Allow-Origin%27+header+is+present+on+the+requested+resource – Quentin Jul 30 '14 at 13:38

1 Answers1

0

You have a typo, should be geocoding_results instead of geocodingResults:

alert(data.geocoding_results.COORDINATES.latitude);   
antyrat
  • 27,479
  • 9
  • 75
  • 76