내 jqgrid가 내 PHP 파일에서 반환 된 json 데이터를 표시하지 않습니다. PHP 파일 json 데이터를 제대로 생성하지만 내 jqgrid html 파일이 표시되지 않습니다. 나는 이유를 찾는다. 도와주세요.jqgrid가 PHP json 데이터를 표시하지 않습니다.
myfirstgrid.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Address</title>
<link rel="stylesheet" type="text/css" media="screen" href="css/ui-lightness/jquery- ui-1.10.3.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />
<script src="js/jquery-1.9.0.min.js" type="text/javascript"></script>
<script src="js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.src.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
$("#list").jqGrid({
url: 'example.php',
datatype: 'json',
mtype: "GET",
colNames: ["addressid", "buildingname", "street", "cityid", "countryid", "statteid","pincode","phone","mobile","fax"],
colModel: [
{ name: "addressid", width: 55 },
{ name: "buildingname", width: 90 },
{ name: "street", width: 80, align: "right" },
{ name: "cityid", width: 80, align: "right" },
{ name: "countryid", width: 80, align: "right" },
{ name: "stateid", width: 150, align: "right" },
{ name: "pincode", width: 150, align: "right" },
{ name: "phone", width: 150, align: "right" },
{ name: "mobile", width: 150, align: "right" },
{ name: "fax", width: 150, align: "right" }
],
pager: "#pager",
rowNum: 10,
rowList: [10, 20, 30],
sortname: "invid",
sortorder: "desc",
viewrecords: true,
gridview: true,
autoencode: true,
caption: "Address"
});
});
</script>
</head>
<body>
<table id="list"><tr><td></td></tr></table>
<div id="pager"></div>
</body>
</html>
example.php
<?php
// initialization
$dbhost = "";
$dbuser = "root";
$dbpassword = "[email protected]#";
$database = "dbeg";
// connect to the database
$db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: ");
mysql_select_db($database) or die("Database connection error.");
// get the count of rows
$result = mysql_query("SELECT * FROM Address");
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$count = $row['count'];
// create a response array from the obtained result
$i = 0;
while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo json_encode($row);
}
mysql_close($db);
?>
example.php 출력
{ "addressid": "101", "buildingname" "Sundale", "street": "도시": "652", "countryid": "6", "statteid": "65", "pincode": "656665", "phone": "986346654 ","mobile ":"8233 43454 ","팩스 ":"554332 "}