JSON值转换成HTML表格 [英] JSON values into HTML table
本文介绍了JSON值转换成HTML表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在同一个文件夹中有 table.html , data.php 和 json.csv 。
data.php 正在做
fopen(json.csv,r)
从 json.csv 。 如何将JSON对象显示为 table.html 中的表格?
< html>
< head>
< script type =text / javascriptsrc =jquery.js>
函数display(){
$ .post('data.php',function(data){
$(#txtJSON)。html(data);
} );
}
< / script>
< / head>
< body onload =display()>
< table id =#jobtable>
< input type =textid =txtJSON/>
< / table>
< / body>
< / html>
解决方案
Zach Hunter写了一篇关于如何做的非常好的教程这件事。给它一个旋风:
http://www.zachhunter.com/2010/04/json-objects-to-html-table/
I have a table.html, data.php and json.csv within the same folder.
data.php is doing fopen("json.csv","r")
to read from json.csv.
How can I display the JSON objects as a table within table.html?
<html>
<head>
<script type="text/javascript" src="jquery.js">
function display(){
$.post('data.php',function(data){
$("#txtJSON").html(data);
});
}
</script>
</head>
<body onload="display()">
<table id="#jobtable">
<input type="text" id="txtJSON" />
</table>
</body>
</html>
解决方案
Zach Hunter wrote a very nice tutorial on how to do this very thing. Give it a whirl:
http://www.zachhunter.com/2010/04/json-objects-to-html-table/
这篇关于JSON值转换成HTML表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文