我挣扎了很长时间将json数据加载到HTML表..? [英] I struggled for a long time to load json data to HTML table..?
本文介绍了我挣扎了很长时间将json数据加载到HTML表..?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< !DOCTYPE html >
< html >
< head >
< script type = text / javascript src = http://ajax.googleapis .com / ajax / libs / jquery / 1.6.2 / jquery.min.js > < / script > ;
< script >
$( function (){
// var dmJSON =http://api.dailymile.com/entries.json?callback=?;
var dmJSON = http:// localhost:61397 / CompanyRestService.svc / GetCompID / 155?callback ?=跨度>;
$ .getJSON(dmJSON, function (data){
alert( 这个方法的值不能来......?);
$ .each(data.SelectCompanyDetailsResult,函数(i,f){
var tblRow = < tr> + < td> + f.AliasName + < / td> + < td> + f.CIN + < / td> + < / tr>
$(tblRow).appendTo( #entrydata tbody);
});
}
);
});
< / script >
< / head >
< body >
< div class = < span class =code-keyword> wrapper >
< div class = 个人资料 >
< table id = entrydata border = 1 >
< thead >
< th > AliasName < / th >
< th > CIN < / th >
< / thead >
< tbody > < span class =code-keyword>< / tbody >
< / table >
< / div >
< / div >
< / body >
< / html >
来自我的Json输出:
{SelectCompanyDetailsResult:[{AliasName:HCL,CIN:U72900Te2003P1699, 网站:www.okdude.co}]}
我的尝试:
我挣扎了很长时间把Json数据加载到html表... plz help
解决方案
( function (){
// var dmJSON =http:// api.dailymile.com/entries.json?callback =?;
var dmJSON = http:// localhost:61397 / CompanyRestService.svc / GetCompID / 155?callback =?;
.getJSON(dmJSON, function (data){
alert( 值不能来这个方法..?);
.each(data.SelectCompanyDetailsResult, function (i,f){
var tblRow = < span class =code-string>< tr> + < td> + f.AliasName + < / td> + < td> + f.CIN + < / td> + < / tr> 跨度>
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"> </script>
<script>
$(function () {
//var dmJSON = "http://api.dailymile.com/entries.json?callback=?";
var dmJSON = "http://localhost:61397/CompanyRestService.svc/GetCompID/155?callback=?";
$.getJSON(dmJSON, function (data) {
alert("The values can't come this method..?");
$.each(data.SelectCompanyDetailsResult, function (i, f) {
var tblRow = "<tr>" + "<td>" + f.AliasName + "</td>" + "<td>" + f.CIN + "</td>" + "</tr>"
$(tblRow).appendTo("#entrydata tbody");
});
}
);
});
</script>
</head>
<body>
<div class="wrapper">
<div class="profile">
<table id="entrydata" border="1">
<thead>
<th>AliasName</th>
<th>CIN</th>
</thead>
<tbody></tbody>
</table>
</div>
</div>
</body>
</html>
exaple my Json output:
{"SelectCompanyDetailsResult":[{"AliasName":"HCL","CIN":"U72900Te2003P1699","Websites":"www.okdude.co"}]}
What I have tried:
I struggled for a long time To load Json data to html table...plz help
解决方案
(function () { //var dmJSON = "http://api.dailymile.com/entries.json?callback=?"; var dmJSON = "http://localhost:61397/CompanyRestService.svc/GetCompID/155?callback=?";
.getJSON(dmJSON, function (data) { alert("The values can't come this method..?");
.each(data.SelectCompanyDetailsResult, function (i, f) { var tblRow = "<tr>" + "<td>" + f.AliasName + "</td>" + "<td>" + f.CIN + "</td>" + "</tr>"
这篇关于我挣扎了很长时间将json数据加载到HTML表..?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文