<!DOCTYPE html>
<html lang="en">
<head>
<!-- The jQuery library is a prerequisite for all jqSuite products -->
<script type="text/ecmascript" src="js/jquery.min.js"></script>
<!-- This is the Javascript file of jqGrid -->
<script type="text/ecmascript" src="js/jquery.jqGrid.min.js"></script>
<!-- This is the localization file of the grid controlling messages, labels, etc. -->
<!-- We support more than 40 localizations -->
<script type="text/ecmascript" src="js/i18n/grid.locale-en.js"></script>
<!-- A link to a jQuery UI ThemeRoller theme, more than 22 built-in and many more custom -->
<link rel="stylesheet" type="text/css" media="screen" href="css/jquery-ui.min.css" />
<!-- The link to the CSS that the grid needs -->
<link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />
<meta charset="utf-8" />
<title>jqGrid Loading Data - JSON</title>
</head>
<body>
<table id="jqGrid"></table>
<div id="jqGridPager"></div>
<script type="text/javascript"> 当我使用json文件时,它可以工作:
$(document).ready(function () {
$("#jqGrid").jqGrid({
url: 'data.json',
datatype: "json",
colModel: [
{ label: 'FirstName', name: 'FirstName', width: 175 },
{ label: 'LastName', name: 'LastName', width: 190 }
],
viewrecords: true, // show the current page, data rang and total records on the toolbar
width: 780,
height: 200,
rowNum: 30,
loadonce: true, // this is just for the demo
pager: "#jqGridPager"
});
});但是如果我使用后端应用程序的url (Spring boot JPA):
http://localhost:8080/customer这是一张图片:

我将url替换为:
url: 'http://localhost:8080/customer',jqgrid中没有记录?!!
这是一张图片:

发布于 2018-07-22 19:49:55
您可以在本地将jqgrid代码作为文件运行,而不是从服务器运行-即file:///.../index.html.。您应该通过示例从web服务器运行此代码,如下所示
http://localhost:8000/index.html然后你可以使用你指向的url。
https://stackoverflow.com/questions/51455189
复制相似问题