resonsehandler 接受服务端传过来的数据,然后在这个函数里处理好要显示的数据在return个table显示
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<title>bootstrapTable</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/> <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script> <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> <!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/bootstrap-table.min.css"> <!-- Latest compiled and minified JavaScript -->
<script src="https://unpkg.com/[email protected]/dist/bootstrap-table.min.js"></script>
<!-- Latest compiled and minified Locales -->
<script src="https://unpkg.com/[email protected]/dist/locale/bootstrap-table-zh-CN.min.js"></script> <link href="" rel="stylesheet">
<script src="" type="text/javascript"></script>
<style> </style>
</head> <body>
<table id="table"></table> <script>
$(function() {
$('#table').bootstrapTable({
url: 'json/353.json',
columns: [{
field: 'date',
title: 'Date Stamp',
sortable: true
}, {
field: 'm_type',
title: 'Type',
sortable: true
}, {
field: 'msdn',
title: 'MSDN',
sortable: true
}, {
field: 'file_name',
title: 'File Name',
sortable: true
}, {
field: 'message',
title: 'Message',
sortable: true
}],
responseHandler: function (res) { console.log(res)
return res.messages
}
})
})
</script> </body>
</html>
json:
{
"messages": [
{
"id": 652,
"session_id": 8965861649940144331,
"date": "2014-12-17T01:01:09Z",
"m_type": "Error",
"message": "could not find a matching MDF file for legacy SQL selection $SQL:\\(local)\\Adams",
"file_name": "$SQL:\\(local)\\Adams",
"msdn": 33
},
{
"id": 653,
"session_id": 8965861649940144331,
"date": "2014-12-17T01:01:10Z",
"m_type": "Error",
"message": "could not find a matching MDF file for legacy SQL selection $SQL:\\(local)\\TRAINING",
"file_name": "$SQL:\\(local)\\TRAINING",
"msdn": 33
}
],
"session_id": 8965861649940144331,
"date": "2014-12-17T01:55:14Z",
"client_date": "2014-12-16T19:55:14Z",
"actual_cpu": "",
"licensed_cpu": "",
"license": 1,
"brand": 2,
"account": 215,
"computer": 289,
"regcode": "1:2:215:289"
}