Javascript: Passing JSON requests to a new page
I am generating nearest Google Places locations based on a user's geolocation here:
http://sandrayoon.com/UAI/www3/placesstyle.php
When one clicks on a location name, it is creating a dynamic url to request JSON from Google Places for details about the location:
a.href = "https://maps.googleapis.com/maps/api/place/details/json?reference="+place.reference+"&sensor=true&key=xxxxxxxxxxx";
a.innerHTML = place.name;
This URL is just a request fo开发者_开发技巧r JSON, but what I need is that when the user clicks a location they are taken to another page that begins to process the JSON.
How can I pass this JSON request to a new page that then processes the JSON from Google Places with a user click?
Have you considered using AJAX to obtain that JSON data and processing it right there in the page, without navigating away?
If you want a dedicated page for displaying place details, you will need to create a new page, with a URL that contains the place reference. From there, you can use AJAX to call the Google JSON URL and process the place details.
http://sandrayoon.com/UAI/www3/places.php?reference=place_reference
So, with a URL like above, you can retrieve the place `reference' and build the proper Google Places JSON URL. You can then issue an AJAX request against that URL to process the JSON response.
精彩评论