0

I'm attempting to load a series of json results on GitHub into a table. The gist can be found here. I've had a look at this question which helps with the population of the table. However, I'm having trouble retrieving the data from the gist.

I've modified the data section of the question as below

<script type="text/javascript">
    var $table = $('#table');
    $.getJSON('https://gist.githubusercontent.com/TheMightyLlama/9f4f1b4c2c078a6080c9212aba6beb59/raw/092fc02afcbd11ea26e7a08541b8dfae4748218a/News%2520Summary%2520Sample', function(mydata) {
  });

  $(function () {
      $('#table').bootstrapTable({
        data: mydata
      });
  });
</script>

And the table as below:

<div class="container">
  <table id="table" data-height="460">
    <thead>
      <tr>
        <th data-field="title">Title</th>
        <th data-field="date">Date</th>
        <th data-field="category">Category</th>
      </tr>
    </thead>
  </table>
</div>
TheMightyLlama
  • 1,243
  • 1
  • 19
  • 51

1 Answers1

0

The variable mydata you used in getJSON function is local variable and that was just created at the time when that function called and can only usable within that function. Write the load table code inside getJSON Here is JSFiddle Working Link

var $table = $('#table');
$.getJSON('https://gist.githubusercontent.com/TheMightyLlama/9f4f1b4c2c078a6080c9212aba6beb59/raw/092fc02afcbd11ea26e7a08541b8dfae4748218a/News%2520Summary%2520Sample', function(mydata) {
    $('#table').bootstrapTable({
        data: mydata
    });
});