0

In the linked jsfiddle I am trying to output a certain result from the JSON. I assume the issue is the line

var address = data[results][0][address_components][1][long_name];

but through trial and error I am still unable to target the desired data.

http://jsfiddle.net/JzMuy/

Many thanks

Ollie Jones
  • 437
  • 1
  • 9
  • 16
  • (1) You have a same-origin violation: *"XMLHttpRequest cannot load `http://maps.googleapis.com/maps/api/geocode/json?latlng=54.9882,-1.5747&sensor=false`. Origin `http://fiddle.jshell.net` is not allowed by Access-Control-Allow-Origin."* (2) `results`, `address_components`, and `long_name` are treated as undefined variables. – Felix Kling May 12 '12 at 18:18

1 Answers1

2

Actually the problem is that you cannot preform a Cross Site access request. You either have to do it with server side code or utilize the JSONP api (if it provides it)

JaredMcAteer
  • 21,688
  • 5
  • 49
  • 65
  • assuming I can't use PHP or any other server side language how would I go about extacting this data? Thanks – Ollie Jones May 12 '12 at 18:25
  • 1
    Here a question that should answer that http://stackoverflow.com/questions/2921745/how-to-make-cross-domain-ajax-calls-to-google-maps-api – JaredMcAteer May 12 '12 at 18:33