[Solved] jQuery help needed with currency converter [closed]


You should really have looked into jQuery documentation as this is all basic stuff, but I am feeling generous:

The following subscribes to the “DOM ready event”, so that your code will only run after the DOM elements are all loaded:

$(document).ready(function() {

Then it runs an Ajax HTTP GET request to the specified URL. On its successful completion the server data will be passed to the supplied callback function in the first parameter (called data in your example). The data will be in the form of a JavaScript object with various properties:

$.get("https://openexchangerates.org/api/latest.json?app_id=[MY_APP_ID]", function(data) {

Extract properties from the object:

    kroner = (data.rates.DKK)
    euro = (data.rates.EUR)
    pound = (data.rates.GBP)
    baht = (data.rates.THB)
    dollars = (data.rates.USD)

Store the values found into specific HTML elements, each found by ID (# = search by ID). So the first one will look for an element with id="DKK" and replace the text content of that matching element:

    $("#DKK").text(kroner); 
    $("#EUR").text(euro);
    $("#GBP").text(pound);
    $("#THB").text(baht);
    $("#USD").text(dollars);

Job done…

The upshot of all this is to request data from the specified website. When it is returned, extract the various exchange rate values and display them on-screen.

1

solved jQuery help needed with currency converter [closed]