注意:要放到服务器上才能运行
Ajax简单的用法:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<input type="button" id="btn" value="点我进行数据交互"/>
<script src="js/jquery-1.8.3.js"></script>
<script>
$("#btn").click(function(){
$.ajax({
type: "post",
url: "data.json",
//success会在成功接收到返回数据后触发
success: function(res) {
console.log(res);
}
})
})
</script>
</body>
</html>