Why I cannot load json data use data-url?
See original GitHub issueDescription
I want to use bootstrap-table in a Pug template and load a json file on the server.
I put the table in a bootstrap modal. the code is like:
link(rel='stylesheet', href='https://cdn.jsdelivr.net/npm/bootstrap@4.5.0/dist/css/bootstrap.min.css', integrity='sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk', crossorigin='anonymous')
link(href='https://unpkg.com/bootstrap-table@1.18.0/dist/bootstrap-table.min.css', rel='stylesheet')
button.btn.btn-primary.btn-lg.btn-block(type='button', data-toggle='modal', data-target='#priceTable')
| Preview Data
#priceTable.modal.fade(tabindex='-1', role='dialog')
.modal-dialog(role='document')
.modal-content
.modal-header
h5.modal-title Preview
button.close(type='button', data-dismiss='modal', aria-label='Close')
span(aria-hidden='true') ×
.modal-body
table#table(data-toggle='table', data-height='299', data-url=json_path)
thead
tr
th(data-field="index") Size
th(data-field="goat") Goat
th(data-field="stockX") StockX
.modal-footer
button.btn.btn-secondary(type='button', data-dismiss='modal') Close
a.btn.btn-success(download=file_name href=file_path) Download
script.
var $table = $('#table')
$(function() {
$('#modalTable').on('shown.bs.modal', function () {
$table.bootstrapTable('resetView')
})
})
script(src='https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js', integrity='sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj', crossorigin='anonymous')
script(src='https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js', integrity='sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo', crossorigin='anonymous')
script(src='https://cdn.jsdelivr.net/npm/bootstrap@4.5.0/dist/js/bootstrap.min.js', integrity='sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI', crossorigin='anonymous')
script(src='https://unpkg.com/bootstrap-table@1.18.0/dist/bootstrap-table.min.js')
The json file is like:
[
{
"index":"4",
"goat":380.0,
"stockX":375
},
{
"index":"5",
"goat":340.0,
"stockX":349
},
{
"index":"6",
"goat":320.0,
"stockX":344
},
{
"index":"7",
"goat":335.0,
"stockX":339
},
{
"index":"8",
"goat":398.0,
"stockX":389
},
{
"index":"9",
"goat":405.0,
"stockX":398
},
{
"index":"10",
"goat":410.0,
"stockX":410
},
{
"index":"11",
"goat":400.0,
"stockX":398
},
{
"index":"12",
"goat":380.0,
"stockX":383
},
{
"index":"13",
"goat":330.0,
"stockX":324
},
{
"index":"14",
"goat":345.0,
"stockX":338
},
{
"index":"15",
"goat":359.0,
"stockX":304
},
{
"index":"4.5",
"goat":355.0,
"stockX":400
},
{
"index":"5.5",
"goat":360.0,
"stockX":350
},
{
"index":"6.5",
"goat":317.0,
"stockX":315
},
{
"index":"7.5",
"goat":339.0,
"stockX":375
},
{
"index":"8.5",
"goat":400.0,
"stockX":415
},
{
"index":"9.5",
"goat":429.0,
"stockX":425
},
{
"index":"10.5",
"goat":385.0,
"stockX":390
},
{
"index":"11.5",
"goat":415.0,
"stockX":399
},
{
"index":"12.5",
"goat":360.0,
"stockX":345
},
{
"index":"18",
"goat":null,
"stockX":5000
}
]
However the data cannot load. The browser act as Loading the data all the time.
What’s my problem and how to fix it?
P.S the json_path
is a variable that the content is a string of the correct path of the json file.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Bootstrap - My table can't read a local JSON file - Stack Overflow
If you want to load a local json file, try like below. function nameFormatter(value) { return 'Formatted ' + value } var data...
Read more >JSON data adapter doesn't read data from the URL
I have an API working and can get data from it on POSTMAN using the correct authentication details and parameters of the GET...
Read more >Content Types - ESBuild
Content Types. All of the built-in content types are listed below. Each content type has an associated "loader" which tells esbuild how to...
Read more >Load JSON - APOC Extended Documentation - Neo4j
The Load JSON procedures retrieve data from URLs or maps and turn it into map value(s) for Cypher to consume. Cypher has support...
Read more >load json data url or api with javascript [ javascript ] - KruXoR
javascript load json data url or api with javascript const data = null; ... Cannot set properties of null (setting onclick) check url...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Try using codepen for an example online https://codepen.io/
Try to use the non-slim version of jquery https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js
@favy87 Nice, non-slim jquery did the trick