load(url,[data],[callback]) 载入远程 HTML 文件代码并插入至 DOM 中。 默认使用 GET 方式 - 传递附加参数时自动转换为 POST 方式。jQuery 1.2 中,可以指定选择符,来筛选载入的 HTML 文档,DOM 中将仅插入筛选出的 HTML 代码。语法形如 "url #some > selector"。请查看示例。--------------------------------------------------------------------------------Load HTML from a remote file and inject it into the DOM. A GET request will be performed by default - but if you pass in any extra parameters then a POST will occur. In jQuery 1.2 you can now specify a jQuery selector in the URL. Doing so will filter the incoming HTML document, only injecting the elements that match the selector. The syntax looks something like "url #some > selector". See the examples for more information. 返回值 jQuery参数 url (String) : 待装入 HTML 网页网址。data (Map) : (可选) 发送至服务器的 key/value 数据。callback (Callback) : (可选) 载入成功时回调函数。示例 加载文章侧边栏导航部分至一个无序列表。 HTML 代码:<b>jQuery Links:</b> <ul id="links"></ul> jQuery 代码:$("#links").load("/Main_Page #p-Getting-Started li"); --------------------------------------------------------------------------------加载 feeds.html 文件内容。 jQuery 代码:$("#feeds").load("feeds.html"); --------------------------------------------------------------------------------同上,但是以 POST 形式发送附加参数并在成功时显示信息。 jQuery 代码: $("#feeds").load("feeds.php", {limit: 25}, function(){ alert("The last 25 entries in the feed have been loaded"); });
载入远程 HTML 文件代码并插入至 DOM 中。
默认使用 GET 方式 - 传递附加参数时自动转换为 POST 方式。jQuery 1.2 中,可以指定选择符,来筛选载入的 HTML 文档,DOM 中将仅插入筛选出的 HTML 代码。语法形如 "url #some > selector"。请查看示例。--------------------------------------------------------------------------------Load HTML from a remote file and inject it into the DOM.
A GET request will be performed by default - but if you pass in any extra parameters then a POST will occur. In jQuery 1.2 you can now specify a jQuery selector in the URL. Doing so will filter the incoming HTML document, only injecting the elements that match the selector. The syntax looks something like "url #some > selector". See the examples for more information.
返回值
jQuery参数
url (String) : 待装入 HTML 网页网址。data (Map) : (可选) 发送至服务器的 key/value 数据。callback (Callback) : (可选) 载入成功时回调函数。示例
加载文章侧边栏导航部分至一个无序列表。 HTML 代码:<b>jQuery Links:</b>
<ul id="links"></ul>
jQuery 代码:$("#links").load("/Main_Page #p-Getting-Started li");
--------------------------------------------------------------------------------加载 feeds.html 文件内容。 jQuery 代码:$("#feeds").load("feeds.html");
--------------------------------------------------------------------------------同上,但是以 POST 形式发送附加参数并在成功时显示信息。 jQuery 代码: $("#feeds").load("feeds.php", {limit: 25}, function(){
alert("The last 25 entries in the feed have been loaded");
});