日期:2014-05-16  浏览次数:20329 次

jquery的load()方法
jquery里 关于load()方法的一段描述,没看明白,希望有高手赐教。

http://api.jquery.com/load/


Script Execution
When calling .load() using a URL without a suffixed selector expression, the content is passed to .html() prior to scripts being removed. This executes the script blocks before they are discarded. If .load() is called with a selector expression appended to the URL, however, the scripts are stripped out prior to the DOM being updated, and thus are not executed. An example of both cases can be seen below:

Here, any JavaScript loaded into #a as a part of the document will successfully execute.

$('#a').load('article.html');
However, in the following case, script blocks in the document being loaded into #b are stripped out and not executed:

$('#b').load('article.html #target');

------解决方案--------------------
Assembly code

载入远程 HTML 文件代码并插入至 DOM 中。

默认使用 GET 方式 - 传递附加参数时自动转换为 POST 方式。jQuery 1.2 中,可以指定选择符,来筛选载入的 HTML 文档,DOM 中将仅插入筛选出的 HTML 代码。语法形如 "url #some > selector"。请查看示例。