首页 > 代码库 > load()方法

load()方法

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>loading</title>
<script src="http://www.mamicode.com/scripts/jquery-1.3.1.js" type="text/javascript"></script>
<style>
.container{
width: 60%;
margin: 0 auto;
border:1px solid #666;
}
.comment{
background-color: #cfcfcf;
}

</style>
</head>
<body>
<div class="container">
<input type="button" id="send" value="http://www.mamicode.com/Ajax获取">
<div class="comment">已有评论</div>
<div id="resText"></div>
</div>
<script type="text/javascript">
$("#send").click(function() {
$("#resText").load("text.html",function(responseText,textStatus,XMLHttpRequest) {
alert(responseText);
alert(textStatus);
alert(XMLHttpRequest);

});
});n
</script>
</body>
</html>

//要加载的文件text.html,如下代码

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>loading</title>
</head>
<body>
<div class="comment">
<h6>张三</h6>
<p class="para">学生1</p>
</div>
<div class="comment">
<h6>李四</h6>
<p class="para">学生2</p>
</div>
<div class="comment">
<h6>小明</h6>
<p class="para">学生3</p>
</div>
</body>
</html>

 

load()方法