Serhiy
Serhiy

Reputation: 2555

Why does jquery $.get fail where .load() works?

Works

    $('#content').load('/in #overview');

Fails

    $.get('/in', function(data){
      $(data).find("#overview").appendTo("#content");
    });

The response is slow however when I console.log the data I get with the .get(), all the data shows up.

Upvotes: 2

Views: 41

Answers (1)

epascarello
epascarello

Reputation: 207511

My guess is that overview is not a child element so you need to use filter and not find. Jquery filters out html, head, and body elements so their children are all on the same level.

$(data).find("#overview").appendTo("#content");

needs to be

$(data).filter("#overview").appendTo("#content");

Upvotes: 1

Related Questions