-1

I want to Show data from API JSON to html table

this is the link

https://openexchangerates.org/api/latest.json?app_id=c8e005009e5946f58356aa9a5fa7f5dd

<html>
<body>
<table>
  <thead>
    <tr>
      <th>Currency</th>
      <th>Value</th>
      <th>selling rate</th>
      <th>buying rate</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>data from api</td>
      <td>data from api</td>
    </tr>
  </tbody>
</body>
</html>

All I want to know is how to get data from API

Thanks

Stefan Becker
  • 5,695
  • 9
  • 20
  • 30
  • 1
    You can search sample code from google using "jquery and parse JSON data" keyword. – The KNVB Feb 11 '19 at 10:01
  • Welcome to StackOverflow. Please have a look [How to Ask page](https://stackoverflow.com/help/how-to-ask) maybe you will get more answers... – Angel M. Feb 11 '19 at 10:21

2 Answers2

0

Make an ajax call to the above the API using

$.ajax({
    type: "Get",
    url: 'https://openexchangerates.org/api/latest.jso',
    data: {app_id:c8e005009e5946f58356aa9a5fa7f5dd}
    success:function(data){
            //do something like this
            var tbody_str="";
            $(data.rates).each(function(key,value){
               tbody_str = tbody_str + "<tr><td> data.key</td><td>data.value</td></tr>
   });
});

If you are using simple jquery. So I prefer constructing your tablerows as string and append it to table body.

Aravind Anil
  • 153
  • 1
  • 9
-1

Without Jquery: https://blog.garstasio.com/you-dont-need-jquery/ajax/

With Jquery: How to parse JSON data with jQuery / JavaScript?

Barry
  • 357
  • 1
  • 11