Use Jquery Selectors on $.AJAX loaded HTML?

前端 未结 9 878
没有蜡笔的小新
没有蜡笔的小新 2020-11-27 11:30

I have

$.ajax({
  url: identity,
  success: function(data) { ProcessIdentityServer(data) }
});

When \'data\' is returned, is there a way to

9条回答
  •  野性不改
    2020-11-27 12:26

    One note I will add which is from a similar problem on here is that if your AJAX returns the following:

    Hello
    World

    The following jQuery Won't work:

    $(data).find('div.test');
    

    as the divs are top level elements and data isn't an element but a string, to make it work you need to use .filter

    $(data).filter('div.test');
    

提交回复
热议问题