Guest Posted May 28, 2020 Posted May 28, 2020 Site URL: https://www.maestros-online.com Hi all, Very new to web design so apologies if this is a basic question. I'm looking to have my site display currencies in plain text on the home page. For now, I just want to be able to fetch the visitor IP and produce a symbol based on the location. IP Stack has a free API that I can use, and looking through the documentation, I assume I need to inject this code into the header script to log in and fetch the Symbol variable: <script> // set endpoint and your access key var ip = '134.201.250.155' var access_key = 'APIKEY'; // get the API result via jQuery.ajax $.ajax({ url: 'http://api.ipstack.com/' + ip + '?access_key=' + access_key, dataType: 'jsonp', success: function(json) { // output the "symbol" object inside "currency" alert(json.currency.symbol); } }); </script> So I have an alert - json.currency.symbol, but how would I then print this in the text? I assume I need to create a source code block, and then do something like: <script> var output = document.getelementbyID('output'); output.innerHTML= json.currency.symbol; </script> Am I anyway near on this? Thanks for the help
Recommended Posts
Archived
This topic is now archived and is closed to further replies.