How to simply convert parsed json data from URL to wordpress widget html table
Asked By: user3152883
Originally Asked On: 2014-01-02 08:19:10
Asked Via: stackoverflow
Hello I’ve been searching the internet for about a couple of days now but I only get lost in the deepness of the subject.
What my aim is to get the json data from this URL: https://www.btcturk.com/api/ticker which is something like this;
{"high":1565.01,"last":1536.90,"timestamp":1388632896.0,"bid":1540.0,"volume":50.76,"low":1534.00,"ask":1552.00}
And I want to print / display / visualize some of the values in html table format, something like this;
<table border="1"> <tr> <td>Alış (Bid): </td> <td>bid value from json</td> </tr> <tr> <td>Satış (Ask): </td> <td>ask value from json</td> </tr> </table>
Please notice that the column1 is custom text and column2 is the related jason data.
That’s it, I just want to insert the needed code into the HTML (Text ) Widget in WordPress.
I’m not even sure if I need a plugin to do this, or if I need to download jquery.js file to my server can read it externally…
Any help, suggestion, guidance or any kind of reply is greatly appreciated.
I thank you all in advance.
He received 1 answers
without selecting any answers.
If the selected answer did not help you out, the other answers might!
All Answers For: How to simply convert parsed json data from URL to wordpress widget html table
Kishorevarma’s answer to
How to simply convert parsed json data from URL to wordpress widget html table
if your current page where you want to put the widget is in the same domain, you can use the below snippet as text/html widget “assuming your page in the same domain https://www.btcturck.com“
<div class="result"></div> <script type="text/javascript"> window.onload = function() { jQuery.ajax( { url: "https://www.btcturk.com/api/ticker", }). done( function( data ) { var data = JSON.parse(data); html = '<table><tr><td>BID</td><td>'+data.bid+'</td></table>'; $('.result').html(html); }); }; </script>
I have used window onload because I don’t know when your jquery library will be loaded.
Of course, you should really check out the original question.
The post How to simply convert parsed json data from URL to wordpress widget html table appeared first on Tech ABC to XYZ.