jquery Ajax
.load( url [, data ] [, complete ] )
Description: Load data from the server and place the returned HTML into the matched elements.
说明:从服务器加载数据和将返回的HTML放入匹配的元素。
-
url 地址
Type: String
A string containing the URL to which the request is sent. -
data 数据
Type: PlainObject or String
A plain object or string that is sent to the server with the request.
发送到服务器的数据 -
complete function(response,status,xhr)
Type: Function( String responseText, String textStatus, jqXHR jqXHR )
A callback function that is executed when the request completes.
当请求完成时,执行的回调函数。
header.html
<style>
header {
height: 45px;
line-height: 45px;
}
header ul li {
display: inline-block;
}
</style>
<header>
<ul>
<li>首页</li>
<li>个人中心</li>
<li>分类</li>
</ul>
</header>
index.html
<div id="header"></div>
<script>
$(function(){
$('#header').load('header.html')
})
</script>