【发布时间】:2010-11-06 05:25:06
【问题描述】:
好的,这真的让我很沮丧,因为我之前已经这样做了一百次,但这次它不起作用。所以我知道我做错了什么,我就是想不通。
我正在使用 jQuery .get 例程从另一个文件加载 html。我不想使用 .load() 因为它总是替换我正在加载内容的元素的子元素。
这是我的 .get 请求:
$(document).ready(function() {
$.get('info.html', {}, function(html) {
// debug code
console.log($(html).find('ul').html());
// end debug code
});
});
文件“info.html”是一个标准的 xhtml 文件,具有适当的 doctype,正文中唯一的内容是我需要访问的一系列 ul。出于某种原因,find 函数给了我一个空值。
在 firebug 中,GET 请求显示正确的响应文本以及何时运行
console.log(html);
我得到了整个 info.html 作为输出,而不是当前的 console.log 行,正如我所期望的那样。
有什么想法吗?
【问题讨论】:
标签: javascript jquery html ajax