You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can only get this to work if I put the rates in manually:
fx.rates = {
"EUR" : 0.745101, // eg. 1 USD === 0.745101 EUR
"GBP" : 0.647710, // etc...
"HKD" : 7.781919,
"USD" : 1, // always include the base rate (1:1)
/* etc */
}
What I really want is the API to auto update with the latest currency rates.
I wired up the json request:
$.getJSON(
// NB: using Open Exchange Rates here, but you can use any source!
'http://openexchangerates.org/api/latest.json?app_id=[I hid this]', function(data) {
// Check money.js has finished loading:
if (typeof fx !== "undefined" && fx.rates) {
fx.rates = data.rates;
fx.base = data.base;
} else {
// If not, apply to fxSetup global:
var fxSetup = {
rates: data.rates,
base: data.base
}
}
});
But it doesn't with latest currencies. Any ideas?
The text was updated successfully, but these errors were encountered:
Can you specify the error that show up in your console?
I implemented moneyjs yesterday getting the rates from a json data source without problems, maybe your scripts are placed in incorrect order or you're not wrapping the getJSON call in a document ready event?
I can only get this to work if I put the rates in manually:
fx.rates = {
"EUR" : 0.745101, // eg. 1 USD === 0.745101 EUR
"GBP" : 0.647710, // etc...
"HKD" : 7.781919,
"USD" : 1, // always include the base rate (1:1)
/* etc */
}
What I really want is the API to auto update with the latest currency rates.
I wired up the json request:
$.getJSON(
// NB: using Open Exchange Rates here, but you can use any source!
'http://openexchangerates.org/api/latest.json?app_id=[I hid this]', function(data) {
// Check money.js has finished loading:
if (typeof fx !== "undefined" && fx.rates) {
fx.rates = data.rates;
fx.base = data.base;
} else {
// If not, apply to fxSetup global:
var fxSetup = {
rates: data.rates,
base: data.base
}
}
});
But it doesn't with latest currencies. Any ideas?
The text was updated successfully, but these errors were encountered: