<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>测试jquey的ajax方法</title>
<style>
*{
padding:0;
margin:0;
}
#test{
padding: 0;
margin: 0 auto;
width:200px;
height: 400px;
}
#test li{
list-style: none;
width:200px;
text-align: center;
height:30px;
line-height:30px;
border:1px dashed lightgrey;
}
</style>
</head>
<body>
<div id="test"></div>
<script src="jquery-1.8.2.min.js"></script>
<script>
$(function(){
alert(1);
$.ajax({
//请求方式为get
type:"GET",
//json文件位置
url:"sanyuan.html",
//返回数据格式为json
cache: false,
//请求成功完成后要执行的方法
success: function(html){
//使用$.each方法遍历返回的数据date,插入到id为#result中
$("#test").append(html);
}
});
});
</script>
</body>
</html>
Ajax读取本地html文件
最新推荐文章于 2023-07-30 20:58:18 发布