//var el = document.getElementById("putItHere");
var day = document.getElementById("date");
var usd = document.getElementById("usd");
var gdp = document.getElementById("gbp");
var euro = document.getElementById("euro");
// Create the XHR, intitalize the connection with open())
// and send the request ... https://www.quandl.com/resources/api-for-commodity-data
var xhr = new XMLHttpRequest();
//SILVER, https://www.quandl.com/data/LBMA/SILVER-Silver-Price-London-Fixing
xhr.open("GET", "https://www.quandl.com/api/v1/datasets/LBMA/SILVER.json?auth_token=dCkdMBF2jDN6_XfYnkZe&rows=1");
xhr.send();
// Add a listener function to respond to the HTTP response
xhr.addEventListener("readystatechange", function(){
// Check here for new state and HTTP response code
// and write the response to the DIV
if(this.readyState == 4 && this.status == 200){
//el.innerHTML = this.response;
var o = JSON.parse(this.response);
//alert(this.response);
var d = o.data[0][0];
var u = o.data[0][1];
var g = o.data[0][2];
var e = o.data[0][3];
if (d) {
$(date).html(d);
}
if (usd) {
$(usd).html(u);
}
if (gbp) {
$(gbp).html(g);
}
if (euro) {
$(euro).html(e);
}
//"column_names":["Date","USD","GBP","EURO"]
//"data":[["2015-04-30",16.52,10.7099,14.7579
}
});
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.