Jquery find() 在 IE 中花费太多时间

发布于 2024-08-02 08:20:51 字数 188 浏览 2 评论 0 原文

我正在尝试在 Ajax HTML 响应中的 DIV 中查找 HTML:

$j(responseText).find("#my_DIV").html()

这在 FF 中完美运行,但 IE6 似乎挂起并永远等待 find() 完成,是否有解决方法来查找 DIV 或者有什么我可以做的事情我做错了吗?

I am trying to find HTML inside a DIV in the Ajax HTML response:

$j(responseText).find("#my_DIV").html()

This works perfectly in FF but IE6 seems to hang and wait forever for the find() to finish, is there a work around to finding a DIV or is there something I am doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

软糯酥胸 2024-08-09 08:20:51

我认为问题在于 jQuery.clean 函数,如果你传递一个非常大的 HTML,一旦 jquery 必须将所有 html 字符串解析为 dom 节点,你的浏览器将有很多工作要做,如 firefox 比 IE 更快 你只注意到 IE 中的问题。

I think the problem is with jQuery.clean function, if you pass a very large HTML you browser will have a lot of work to do once jquery have to parse all html string into dom nodes, as firefox is faster than IE you only notice the problem in IE.

几度春秋 2024-08-09 08:20:51

如果是 ajax 调用,请尝试减少响应。您没有提及您在服务器端使用的内容 - 但其想法是,如果传入的是 XMLHttpRequest,则您只返回所需的片段。

If it's an ajax call try to trim down the response. You don't mention what you're using on the server side - but the idea is that if it's an XMLHttpRequest coming in you return just the fragment that's needed.

骄傲 2024-08-09 08:20:51

尝试像这样拆分您的代码:

var response = $j(responseText);
var div = response.find("#my_DIV");
var html = div.html();

这样,您将能够准确地看到哪一部分花费了时间。然后,有了更准确的信息,您可以编辑您的问题以提供更多详细信息。

Try splitting up your code like this:

var response = $j(responseText);
var div = response.find("#my_DIV");
var html = div.html();

This way, you'll be able to see precisely which part is taking the time. Then, with that more accurate information, you can edit your question to provide more details.

呆° 2024-08-09 08:20:51

我不确定后代选择器是否使用与 find 方法相同的迭代,但您可以尝试以下代码来查看是否获得更快的响应:

$j(responseText+" #my_DIV").html()

请参阅 后代选择器

I am not sure whether the descendant selector uses the same iteration as the find method, but you can try the following code to see if you get any faster responses:

$j(responseText+" #my_DIV").html()

See the documentation for the descendant selector

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文