views:

185

answers:

4

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?

+1  A: 

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.

Cleiton
A: 

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.

Andy Gaskell
A: 

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.

John Fisher
A: 

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

yuval