我正在尝试设置一个jsgrid,但是我总是得到“未找到”。
这是我的代码:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/momentjs/2.14.1/moment.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/css/bootstrap-datetimepicker.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link type="text/css" rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jsgrid/1.5.3/jsgrid.min.css" />
<link type="text/css" rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jsgrid/1.5.3/jsgrid-theme.min.css" />
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jsgrid/1.5.3/jsgrid.min.js"></script>
<style>
.hide
{
display:none;
}
</style>
<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<title>Set Tariffs</title>
<div class="container">
<br />
<div class="table-responsive">
<div id="grid_table"></div>
</div>
</div>
</body>
</html>
<script>
$(function() {
$("#grid_table").jsGrid({
width: "70%",
height: "auto",
filtering: true,
inserting:true,
editing: true,
sorting: true,
paging: true,
autoload: true,
pageSize: 10,
pageButtonCount: 5,
deleteConfirm: "Do you really want to delete data?",
controller: {
loadData: function(filter){
console.log(filter);
return $.ajax({
type: "GET",
url: "fetch_data.php",
data: filter,
dataType: "json"
}).then(function(result) {
return result.data;
});
},
insertItem: function(item){
return $.ajax({
type: "POST",
url: "fetch_data.php",
data:item
});
},
updateItem: function(item){
return $.ajax({
type: "PUT",
url: "fetch_data.php",
data: item
});
},
deleteItem: function(item){
return $.ajax({
type: "DELETE",
url: "fetch_data.php",
data: item
});
},
},
fields: [
{
name: "PortID",
type: "text",
width: 150
},
{
name: "country",
type: "text",
width: 150,
validate: "required"
},
{
name: "port",
type: "text",
width: 150,
validate: "required"
}
]
})
})
</script>
这是我的fetch_data.php文件的响应:
// 20190623093335 // http://localhost/portar%20feb%202019%20b/fetch_data.php?PortID=&country=&port=
{“ PortID”:“ 19794”,“国家”:“ ZIMBABWE”,“端口”:“ Gwanda”}
我似乎无法使用此值来初始化网格。 有什么想法吗?