我的JSON数据看起来像这样,我试图通过数据表发送它。
JSON数据:
{
"data": [{
"name": "name1",
"value": "value1",
"list": [{
"sname": "sname1",
"svalue": "svalue1"
}, {
"sname": "sname2",
"svalue": "svalue2"
}]
}]
}
JQuery代码:
var pk = $("#pk").val();
console.log(pk);
url="/register/search?id="+pk;
console.log(url);
$('#largeTable').DataTable({
"ajax" : url,
"bDestroy":true,
"columns":[
{"data": "name"},
{"data": "value"},
{"data": "list.sname"},
{"data": "list.svalue"},
{"data": null,"defaultContent":editview}
]
});
HTML code:
<div class="box-body">
<table class="table table-striped table-bordered" id="largeTable" style="background-color: white;" >
<thead style="background-color:#CCE5FF">
<tr>
<th>EName</th>
<th>Value</th>
<th>SuperiorName</th>
<th>SValue</th>
<th>action</th>
</tr>
</thead>
</table>
</div>
我希望在html页面文本框下面获取数据表值。
<form class="form-horizontal" role="form" id="RegistrationForm" >
<div class="col-md-6">
<div class="form-group ">
<label for="ename" class="col-md-4 control-label">EName</label>
<div class="col-md-6">
<input type="text" class="form-control" id="ename" name="ename" placeholder="EName" />
</div>
</div>
<div class="form-group ">
<label for="value" class="col-lg-4 control-label">Value</label>
<div class="col-lg-6">
<input type="text" class="form-control" id="value" placeholder="value"/>
</div>
</div>
<div class="form-group ">
<label for="sname" class="col-lg-4 control-label">Supr.Name</label>
<div class="col-lg-6">
<input type="text" class="form-control" id="sname" name = "sname" placeholder="Supr.Name"/>
</div>
</div>
<div class="form-group ">
<label for="svalue" class="col-lg-4 control-label">SValue</label>
<div class="col-lg-6">
<input type="text" class="form-control" id="svalue" name="svalue" placeholder="SValue"/>
</div>
</div> </div>
</form>