Simple jQuery ajax example not finding elements in returned HTML

后端 未结 4 1443
情话喂你
情话喂你 2020-12-25 08:27

I\'m trying to learn jQuery\'s ajax functions. I\'ve got it working, but jQuery doesn\'t find elements in the returned HTML DOM. In the same folder as jquery, run this page:

4条回答
  •  攒了一身酷
    2020-12-25 08:42

    Why not try this and see what happens:

    $('#testDiv').load('ajaxtest-load.html #wrapper', function(resp) {
        alert(resp);
    });
    

    From the $.load documentation:

    In jQuery 1.2 you can now specify a jQuery selector in the URL. Doing so will filter the incoming HTML document, only injecting the elements that match the selector.

提交回复
热议问题