Search code examples
javascriptbootstrap-table

Javascript Bootstrap table not loading data despite different call syntax attempts


I have a problem when calling the load method from the bootstrap method. My code is on JSFiddle here: https://jsfiddle.net/VGerardsson/uxc8wLq4/23/

I am using JQuery 3.3.1 and bootstrap 4.3.1

I followed the templates and I used several different calls to fill the table. Initially I called a URL to fill the table but this caused a time-out error. My current error, however, is that I can only display an empty table at best.

Using the answers from questions that I checked here on StackOverflow, I couldn't find an answer. I used, amongst other the two methods below. Only the load call returns a result but it is an empty table. the parameter data-toggle="table" is already set.

  $table.bootstrapTable('load', Mydata)
  $table.bootstrapTable({data: data})

Could someone please point me in the right direction? Let me know if the JFiddle is incorrect.


Solution

  • your code had two errors.

    1st: you did not initialize the $table variable. 2nd: you have to provide the data-field attribute in the th tags. I have made the changes, you can have a look at it.

    Make sure to correct the json data as well.

    here's the updated fiddle.

    https://jsfiddle.net/o39z2dse/3/

    Make sure to use the stackoverflow snippet next time to embed code. It's easier to use.