More information about the Underscore mailing list

[_] jquery - $.get - getting a bit of html from a loaded php file

Tim Wintle timwintle at
Fri Sep 23 16:50:16 BST 2011

On Fri, 2011-09-23 at 15:53 +0100, juan kennaugh wrote:
> I wondered about that - but just tried it and no luck.
> data - is a string of HTML  - I can insert that no probs - I just can't 
> select a part of it with a selector.

It's not yet been parsed by the browser yet, so you'll need to force the
browser to do so:

var selection = jQuery("<div>").append(data).find('.content-to-insert';

I double checked jQuery's implementation of .load() and that seems to be
how they do it too. HOWEVER - note the comment in their source:

// inject the contents of the document in, removing the scripts
// to avoid any 'Permission Denied' errors in IE

... so if you want to maintain javascripts it sounds like there might be errors.