Take a typical json..
the google maps api for instance
im trying to run this:
$.get('/properties/get-coordinates/address/<?php print $address;?> ',function(data){
$('#debug').html(data);
alert(data);
});
my debug div then displays the json:
{ "results" : [ { "address_components" : [ { "long_name" : "49", "short_name" : "49", "types" : [ "street_number" ] }, { "long_name" : "Saucel Hill Terrace", "short_name" : "Saucel Hill Terrace", "types" : [ "route" ] }, { "long_name" : "Paisley", "short_name" : "Paisley", "types" : [ "locality", "political" ] }, { "long_name" : "Renfrewshire", "short_name" : "Renfrewshire", "types" : [ "administrative_area_level_3", "political" ] }, { "long_name" : "Renfrewshire", "short_name" : "Renfrewshire", "types" : [ "administrative_area_level_2", "political" ] }, { "long_name" : "Scotland", "short_name" : "Scotland", "types" : [ "administrative_area_level_1", "political" ] }, { "long_name" : "United Kingdom", "short_name" : "GB", "types" : [ "country", "political" ] }, { "long_name" : "PA2 6", "short_name" : "PA2 6", "types" : [ "postal_code_prefix", "postal_code" ] } ], "formatted_address" : "49 Saucel Hill Terrace, Paisley, Renfrewshire PA2 6, UK", "geometry" : { "bounds" : { "northeast" : { "lat" : 55.8379530, "lng" : -4.417937999999999 }, "southwest" : { "lat" : 55.8363920, "lng" : -4.4212770 } }, "location" : { "lat" : 55.83792170, "lng" : -4.421174000000001 }, "location_type" : "RANGE_INTERPOLATED", "viewport" : { "northeast" : { "lat" : 55.83852148029150, "lng" : -4.417937999999999 }, "southwest" : { "lat" : 55.83582351970850, "lng" : -4.4212770 } } }, "partial_match" : true, "types" : [ "street_address" ] }, { "address_components" : [ { "long_name" : "Saucel St", "short_name" : "Saucel St", "types" : [ "route" ] }, { "long_name" : "Paisley", "short_name" : "Paisley", "types" : [ "locality", "political" ] }, { "long_name" : "Renfrewshire", "short_name" : "Renfrewshire", "types" : [ "administrative_area_level_3", "political" ] }, { "long_name" : "Renfrewshire", "short_name" : "Renfrewshire", "types" : [ "administrative_area_level_2", "political" ] }, { "long_name" : "Scotland", "short_name" : "Scotland", "types" : [ "administrative_area_level_1", "political" ] }, { "long_name" : "United Kingdom", "short_name" : "GB", "types" : [ "country", "political" ] }, { "long_name" : "PA1 1", "short_name" : "PA1 1", "types" : [ "postal_code_prefix", "postal_code" ] } ], "formatted_address" : "Saucel St, Paisley, Renfrewshire PA1 1, UK", "geometry" : { "bounds" : { "northeast" : { "lat" : 55.8419450, "lng" : -4.4198480 }, "southwest" : { "lat" : 55.8407950, "lng" : -4.4216290 } }, "location" : { "lat" : 55.84183299999999, "lng" : -4.4200330 }, "location_type" : "GEOMETRIC_CENTER", "viewport" : { "northeast" : { "lat" : 55.84271898029149, "lng" : -4.419389519708498 }, "southwest" : { "lat" : 55.84002101970850, "lng" : -4.422087480291503 } } }, "partial_match" : true, "types" : [ "route" ] } ], "status" : "OK" }
I'm trying to alert out this part:
"location" : { "lat" : 55.84183299999999, "lng" : -4.4200330 }
or even more specifically just get the lat and lng
simple enough?