我是 jQuery 移动开发新手,无法从 JSON 填充 jQuery 移动列表视图。我总是收到错误警报。
这是我的代码:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>listview demo</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css">
<script src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
</head>
<body>
<div data-role="page" id="index">
<div data-role="header">
<h1>jQuery Mobile Example</h1>
</div>
<div data-role="content">
<ul data-role="listview"></ul>
</div>
<script type="text/javascript">
$(document).on('pagebeforeshow', '#index', function()
{
$.ajax
({
url : "http://localhost/Info.php",
dataType: 'json',
success: function (result) {ajax.jsonResult = result;alert('OK');},
error: function (request,error) {alert('error!');}
});
});
</script>
</div>
</body>
</html>