<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script type="text/javascript" src="../js/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
$(function () {
$("a").on("click",function () {
url="../a.json";
args={"time":new Date()};
//url:访问的路径
//args:格式为JSON格式
//$.getJSON 返回的数据都在回调函数的参数里(参数可以任意命名,一般为data)
$.getJSON(url,args,function (data1) {
var name= data1.person.name;
var age=data1.person.age;
$("#sp").append(name);
$("#sp").append(age);
})
return false;
})
})
</script>
</head>
<body>
<a href="hello world">hello</a>
<span id="sp"></span>
</body>
</html>
原文:https://www.cnblogs.com/kukai/p/10864824.html