如何使用jquery将jj数据提取到HTML页面? [英] How to getjson data to HTML page using jquery..?
问题描述
< 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:// localhost: 56132 / CompanyRestService.svc / GetCompnayProductsTestHTML / 75\" 跨度>;
$ .getJSON(dmJSON, function (data){
$ .each(data.GetCompnayProductsTestHTMLResult, function (i,f){
var tblRow = < tr> + < td> + f.ProductId + < / td> + < td> + f.ProductName + < / 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 > ProductId < / th >
< th > ProductName < / th >
< / thead >
< tbody > < / tbody >
< / table >
< / div >
< / div > ;
< / body >
< / html >
Json数据:
{
GetCompnayProductsTestHTMLResult:[{ProductId:2,ProductName:Aquarium Chillers,ParentId:0,NPCMSID:1, Parentname :NULL, NICCode :NULL, NAICSCode :空, 容量 : TSET 的uint:102, IsActive:假 LocationID:75, CreatedBy:0, CreatedDate : 0001-01-01T00:00:00\" , ModifiedBy:0, ModifiedDate: 0001-01-01T00:00:00, 活动:假的, PrjPhaseID:0, FullyQualifiedName:null}]
}
我尝试过:
当以下代码使用时...我没有得到输出
( function (){
var dmJSON = http:// localhost:56132 / CompanyRestService.svc / GetCompnayProductsTestHTML / 75;
.getJSON(dmJSON, function (data){
.each(data.GetCompnayProductsTestHTMLResult , function (i,f){
var tblRow = < tr> + < td> + f.ProductId + < / td> + < td> + f.ProductName + < / td> + < / TR> 中跨度>
<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://localhost:56132/CompanyRestService.svc/GetCompnayProductsTestHTML/75";
$.getJSON(dmJSON, function (data) {
$.each(data.GetCompnayProductsTestHTMLResult, function (i, f) {
var tblRow = "<tr>" + "<td>" + f.ProductId + "</td>" + "<td>" + f.ProductName + "</td>" + "</tr>"
$(tblRow).appendTo("#entrydata tbody");
});
});
});
</script>
</head>
<body>
<div class="wrapper">
<div class="profile">
<table id="entrydata" border="1">
<thead>
<th>ProductId</th>
<th>ProductName</th>
</thead>
<tbody></tbody>
</table>
</div>
</div>
</body>
</html>
Json Data:
{
"GetCompnayProductsTestHTMLResult": "[{"ProductId":2,"ProductName":"Aquarium Chillers","ParentId":0,"NPCMSID":"1","Parentname":null,"NICCode":null,"NAICSCode":null,"Capacity":"tset","Uints":102,"IsActive":false,"LocationID":75,"CreatedBy":0,"CreatedDate":"0001-01-01T00:00:00","ModifiedBy":0,"ModifiedDate":"0001-01-01T00:00:00","Active":false,"PrjPhaseID":0,"FullyQualifiedName":null}]"
}
What I have tried:
when the below code i m using... i am not get output
(function () { var dmJSON = "http://localhost:56132/CompanyRestService.svc/GetCompnayProductsTestHTML/75";
.getJSON(dmJSON, function (data) {
.each(data.GetCompnayProductsTestHTMLResult, function (i, f) { var tblRow = "<tr>" + "<td>" + f.ProductId + "</td>" + "<td>" + f.ProductName + "</td>" + "</tr>"
这篇关于如何使用jquery将jj数据提取到HTML页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!