I am currently learning Java, HTML and CSS so have began making a currency converter to tie these skills together although I am having trouble calling an API and printing the relavant data (exchange rates). Below is my code:
<html>
<head>
<title>API Test</title>
</head>
<body>
<script>
endpoint = 'latest'
access_key = 'xxx';
// get the most recent exchange rates via the "latest" endpoint:
$.ajax({
url: 'http://data.fixer.io/api/' + endpoint + '?access_key=' + access_key,
dataType: 'jsonp',
success: function(json) {
// exchange rata data is stored in json.rates
alert(json.rates.GBP);
// base currency is stored in json.base
alert(json.base);
// timestamp can be accessed in json.timestamp
alert(json.timestamp);
</script>
</body>
</html>
The following code does not print anything at all and I am unsure as to why this is. The code above is straight from the api documentation although as a beginner I feel I may be missing something obvious. Any help as to why this is happening would be appreciated.