openexchangerates / money.js

money.js is a tiny (1kb) javascript currency conversion library, for web & nodeJS
http://openexchangerates.github.io/money.js
MIT License
1.46k stars 127 forks source link

Uncaught fx error #8

Open mwzip opened 11 years ago

mwzip commented 11 years ago

Hello,

money.js seems like a great library, but I can't seem to get it working. No matter what, I always get: "Uncaught fx error" as the javascript console output and the conversions don't seem to be working.

I get this error on a fresh page with just money.js included and the BASIC convert() function being called. To be more specific, the error also says: "b.convert (anonymous function)"

Any ideas?

evert0n commented 11 years ago

If you are loading the rates like in the jquery ajax examples make sure you call fx only after that.

Another point is about where are you calling fx, you can try to call it using window.fx and check if works.

ezkl commented 11 years ago

call it using window.fx

:+1: Works for me.

Iknuts commented 10 years ago

Im having the same problem... my page wont load even after I call the window.fx

I feel I must be missing something. Please help!!

baidru commented 9 years ago

Hi,

I am having the same problem... "Uncaught fx error please guide me how to solved this error IF possible tell me where to write code to fix this.

My Website URL :- http://vandvshop.com/production/

I am in trouble pls help me

Thanks!

JerJohn15 commented 8 years ago

Was this issue ever resolved? I'm having the same problem.

FWSimon commented 8 years ago

same problem here

nsantiago2719 commented 8 years ago

Try using other currencies. Like fx.convert(1000, {from: "GBP", to: "HKD"}); if it works then the problem is in your JSON response. It can't find the currency you are trying to convert. I just noticed this on my current project.

JerJohn15 commented 8 years ago

I ended up resolving my issue, by looking at the money js source code. The line in question was:

// Throw an error if either rate isn't in the rates array
        if ( !rates[to] || !rates[from] ) throw "fx error";

There was no "from" value set in fx.settings, so setting it to my base currency seemed to fix that issue:

fx.settings = { from: "USD"};

. I also had to set the fx.convert function within the function where I make my JSON request and use bind(this) to bind the data.

agucova commented 8 years ago

I don't understand what's happening, but it's not working

mshibl commented 7 years ago

Same issue

maelswarm commented 6 years ago

Same issue

dnlmzw commented 6 years ago

Same issue

karthiknvlr commented 6 years ago

same issue

blackwatertepes commented 6 years ago

+1

iAminaDarwish commented 6 years ago

You'll need to wait until the AJAX request has completed before you can begin processing conversions. If you can't do that, then set default rates ( not the latest / local array of rates), then when you get your ajax request response replace that array with the latest rates. MoneyConverter.base = "USD"; MoneyConverter.rates=[ "AED": 3.673123, "AFN": 69.469, "ALL": 105.04, "AMD": 478.652004, "ARS": 20.1765] axios .get("api/currencies/rates";) .then(function(response) { MoneyConverter.rates = response.data.data; })