Created
April 21, 2020 16:15
-
-
Save pretty25/24d63565b6b862782378fee549d9c5d8 to your computer and use it in GitHub Desktop.
Bikes_availability.html
This file contains 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="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> | |
<script> | |
$(document).ready(function(){ | |
$("button").click(function(){ | |
var str = $("#idOfBikePoint").val(); | |
var url ="https://api.tfl.gov.uk/Place/"+str; | |
$.get(url, function(data, status){ | |
var list = data.additionalProperties; | |
var text =""; | |
for (var item in list) { | |
item = list[ item ]; | |
if(item.key==='NbBikes') | |
{ | |
text = "Available Bikes: "+ item.value; | |
} | |
if(item.key==='NbEmptyDocks') | |
{ | |
text = text + "\nEmpty Docks: "+ item.value; | |
} | |
} | |
alert(text); | |
} | |
); | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
Enter Dock Station Id Here <input type="text" id="idOfBikePoint"> | |
<br/> | |
<button>Click Here To find Available Bikes for the bike point </button> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment