Create HTML table from JSON data with JQUERY or Javascript or ANYTHING
-
Possible Duplicate: http://stackoverflow.com/questions/1051061/convert-json-array-to-an-html-table-in-jquery I'm trying desperately to figure out out to make this table... I have 3 fields i need to be in the same <td> and another field by itself in a <td> I am successfully getting the data with JSON to my page with this code. $.ajax({ url: 'code.php', async: false, dataType: 'json', success: function (json) { window.upc = json.upc; window.img_name = json.img_name; window.quantity = json.quantity; window.description = json.description; } }); how can i get this data to be formatted like i want? |TEXT|image| |TEXT|goes| |TEXT|here| Thanks.
-
Answer:
Check out: http://icanhazjs.com/ STEP 1. - DEFINE YOUR TEMPLATE <script id="template" type="text/html"> <table> <tr> <td>{{quantity}}{{description}}</td><td>{{img_name}}</td> </tr> </table> </script> STEP 2. - RETRIEVE YOUR POPULATED TEMPLATE: $.ajax({ url: 'code.php', async: false, dataType: 'json', success: function (json) { var yourTable = ich.template(json) } }); You can append the variable yourTable to any element on the page.
Devin Prejean at Stack Overflow Visit the source
Related Q & A:
- How to set value in the dropdown from a JSON data list?Best solution by Stack Overflow
- How to display HTML table with angularJS?Best solution by Stack Overflow
- How to store json data in jquery?Best solution by Stack Overflow
- How to read Json Data from online file?Best solution by mkyong.com
- How do you write specific data to an HTML table?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.