Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- </head>
- <body>
- <link rel="stylesheet" href="style.css">
- <script script type="text/javascript"
- src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js">
- </script>
- <script type="text/javascript" src="money.js"></script>
- <script type="text/javascript">// <![CDATA[
- $(document).ready(function(){
- fx.base = "EUR";
- fx.rates = { //will be used if the script can't access openexchangerates.org
- "EUR" : 1, // base rate
- "USD" : 2, // example exchange rate
- }
- fx.settings = {
- from : "EUR",
- to : "USD",
- };
- var amount = 9.99; //example amount of money
- $.getJSON(
- 'http://openexchangerates.org/latest.json?app_id=41ba6462052249d585ddaa71ba762c08&jsoncallback=?', //here lie the exchange rates, jsoncallback=? was added to make cross-domain AJAX request possible
- function jsonCallback(json){
- console.log(json); //and here goes the mistake: "Uncaught SyntaxError: Unexpected token :"
- },
- 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
- }
- }
- }
- );
- var EUR = fx.convert(amount, {to: "USD"});
- console.log(EUR);
- alert(EUR);
- }
- );
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement