I am using bootstrap table to build table with json data dynamically, when i plugged function to consume json from web service the table displays empty rows. I compared the data set and i don't see any errors either. Did anyone face this ? what am i missing ?
Script #1
var data;
$.getJSON("http://xxxxxxxx:8073/data-list", function(json){
data = json;
console.log(" data : "+JSON.stringify(data));
});
/*function to load data to first nav tab map*/
$(function () {
$('#table').bootstrapTable({
data: data
});
});
Log
console.log outputs the data as mentioned below, if i compare between hardcoded json vs json from web service it looks identical.
data : [{"index":1,"name":"MATT","company":"APPLE","key":"123333","description":"Node check"},{"index":2,"name":"Steve","company":"Zynga","key":"124333","description":"Game check"}]
Script #2
The same feature works fine if i have variable holding hardcoded json data.
var data =
[
{
"index": 1,
"name": "MATT",
"company": "APPLE",
"key": "123333",
"description": "Node check"
},
{
"index": 2,
"name": "Steve",
"company": "Zynga",
"key": "124333",
"description": "Game check"
}
]
$(function () {
$('#table').bootstrapTable({
data: data
});
});
View
<tr>
<th class="col-md-5 col-xs-5" data-field="name" data-sortable="true">Name</th>
<th class="col-md-4 col-xs-4" data-field="company" data-sortable="true">Work (Authority)</th>
<th class="col-md-3 col-xs-3" data-field="key" data-sortable="true">Magic Key</th>
</tr>