json文件,名为qqq
[
{
"name":"aaa",
"sex":"男",
"email":"zhangguoli@123.com"
},
{
"name":"bbb",
"sex":"男",
"email":"zhangtieli@123.com"
},
{
"name":"ccc",
"sex":"女",
"email":"zhenjie@123.com"
}
]
<script type="text/javascript" src="jquery-3.2.1.js"></script>
<script type="text/javascript">
var Ajax = function ()
{
$.getJSON ("qqq.json", function (data)
{
$.each (data, function (i, item)
{
$ ("#disp").append ("<h3>" + item.name + "</h3>");
$ ("#disp").append ("<p>" + item.sex + "</p>");
$ ("#disp").append ("<p>" + item.email + "</p>");
});
});
}
</script>
</head>
<body>
<input type="button" value="Ajax提交" onclick="Ajax();" />
<div id="disp"></div>
</body>
偶然的你
相关分类