javascript - Uncaught TypeError: Cannot read property 'ownerDocument' of undefined -


i'm teaching myself ajax ajaxify site. in template, have following js code json data view append data div.

function filter(type) {   $.getjson(     '/activity_stream/global-activity-stream/',      {xhr: "true", filter: type},      function(data) {       $('.maincontent').children().remove();       $(data).appendto('.maincontent');     });   }    $(".btn").click(function () {      filter("recent");    }); } 

i think view returning proper json data not being added .maincontent div.

it gives error:

uncaught typeerror: cannot read property 'ownerdocument' of undefined.

make sure you're passing selector jquery, not form of data:

$( '.my-selector' ) 

not:

$( [ 'my-data' ] ) 

Comments