Created
April 15, 2014 19:23
-
-
Save tkiefhaber/10762321 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script> | |
| </head> | |
| <body> | |
| <p id="demo">Click the button to get your coordinates:</p> | |
| <p id="closest"></p> | |
| <button onclick="getLocation()">Try It</button> | |
| <script> | |
| var demo = document.getElementById("demo"); | |
| var closest = document.getElementById("closest"); | |
| function getLocation() { | |
| if (navigator.geolocation) | |
| { | |
| navigator.geolocation.getCurrentPosition(showPosition); | |
| } | |
| else { | |
| x.innerHTML="Geolocation is not supported by this browser."; | |
| } | |
| } | |
| function showPosition(position) { | |
| demo.innerHTML="Latitude: " + position.coords.latitude + "<br>Longitude: " + position.coords.longitude | |
| var yelp_url = 'http://api.yelp.com/business_review_search?term=pizza&lat=' + position.coords.latitude + '&long=' + position.coords.longitude + '&limit=1&ywsid=6CWb41GEBQ8nZXu8KaInyw' | |
| $.ajax({url: yelp_url, success: function(result){ | |
| alert(result); | |
| closest.innerHTML="hello"; | |
| } }); | |
| } | |
| </script> | |
| </body> | |
| </html> |
or even:
$.get(yelp_url).done(function(result){
alert(result);
closest.innerHTML="hello";
});
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What if you: