注意:要放到服務(wù)器上才能運行
Ajax簡單的用法:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<input type="button" id="btn" value="點我進行數(shù)據(jù)交互"/>
<script src="js/jquery-1.8.3.js"></script>
<script>
$("#btn").click(function(){
$.ajax({
type: "post",
url: "data.json",
//success會在成功接收到返回數(shù)據(jù)后觸發(fā)
success: function(res) {
console.log(res);
}
})
})
</script>
</body>
</html>