Advertisement
Guest User

CurrencyConverter

a guest
Jul 6th, 2017
97
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3.  <head>
  4. </head>
  5. <body>
  6.     <link rel="stylesheet" href="style.css">
  7.     <script script type="text/javascript"
  8. src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js">
  9. </script>
  10.     <script type="text/javascript" src="money.js"></script>
  11.     <script type="text/javascript">// <![CDATA[
  12.     $(document).ready(function(){
  13.       fx.base = "EUR";
  14.       fx.rates = { //will be used if the script can't access openexchangerates.org
  15.     "EUR" : 1, // base rate
  16.     "USD" : 2,          // example exchange rate
  17. }
  18.       fx.settings = {
  19.         from : "EUR",
  20.         to : "USD",
  21.       };
  22.       var amount = 9.99; //example amount of money
  23.       $.getJSON(
  24.           'http://openexchangerates.org/latest.json?app_id=41ba6462052249d585ddaa71ba762c08&jsoncallback=?', //here lie the exchange rates, jsoncallback=? was added to make cross-domain AJAX request possible
  25.          function jsonCallback(json){
  26.   console.log(json); //and here goes the mistake: "Uncaught SyntaxError: Unexpected token :"
  27. },
  28.           function(data) {
  29.               // Check money.js has finished loading:
  30.               if ( typeof fx !== "undefined" && fx.rates ) {
  31.                   fx.rates = data.rates;
  32.                   fx.base = data.base;
  33.               } else {
  34.                   // If not, apply to fxSetup global:
  35.                   var fxSetup = {
  36.                       rates : data.rates,
  37.                       base : data.base
  38.                   }
  39.               }
  40.           }
  41. );
  42.              var EUR = fx.convert(amount, {to: "USD"});
  43.              console.log(EUR);
  44. alert(EUR);
  45.           }
  46.       );
  47. </script>
  48. </body>
  49. </html>
Advertisement
RAW Paste Data Copied
Advertisement