2

I've been referencing adeneo -> How to get the html of a div on another page with jQuery ajax? to assist me with this issue. So this is my code:

$.ajax({url: "../Site/index.html",type: "GET",dataType: "html"}).done(function(data){
    alert(data);
    alert($(data).find("div #content").html());
    $("#siteForm").append($(data).find("div #content").html());             
});

First alert returns: enter image description here

(All of the HTML from the expected page, so working as intended) As you can see, it has returned the div with an id of content.

However the issue is that the second alert is returning undefined. What have I done wrong?

Additionally, alert($(data).find("div #companyID").html()); returns the content within the companyID div... (so working as intended)..... :S

I can't use the .load method because I need the script tags.

Community
  • 1
  • 1
Zze
  • 18,229
  • 13
  • 85
  • 118

1 Answers1

4

Remove space between div and #content find selector

alert($(data).find("div#content").html());
Sreedhar
  • 141
  • 6