DOM loaded through xmlhttprequest not detected by jquery in GM

Hi,

I’m loading content using an XMLHttpRequest and sending it to a

div

on the fly in Greasemonkey. However, when I try to traverse through this newly loaded content and retrieve the innerHTML, jquery returns a null.

My code is as such


var xhReq = new XMLHttpRequest();
 xhReq.open("GET", linksRaw, false);
 xhReq.send(null);
 var serverResponse = xhReq.responseText;
 var tempDiv = document.createElement('div');
tempDiv.setAttribute("id", "myContainer");

tempDiv.innerHTML = serverResponse.replace(/<script(.|\\s)*?\\/script>/g, '');
var letsTry = $("div#myContainer .orgList").html();
alert (letsTry);

The alert returns a “null” when I know that .orgList link has anchor text.

Also, getElementsByClassName isn’t working either.
I’m using the latest update of Greasemonkey and FF 3.6

Thanks

jquery is looking in window.document for your div(the default). It doesn’t exist in any document. You created it but haven’t added it to anything.

Try $(“.orgList”, tempDiv).html()