S
S
Server Bear2021-03-29 00:29:14
AJAX
Server Bear, 2021-03-29 00:29:14

How to select desired content from html received as a result of ajax?

I made an AJAX request and got:

$.get("http://localhost:81/", {}, function (data, status) {
                    let result = html(data); 
                    $("#items").result
                });

But the fact is that not the entire page needs to be displayed from the resulting markup, but only the code enclosed in:
<div id="items">
...
</div>

Help me please!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Belyaev, 2021-03-29
@bingo347

https://developer.mozilla.org/en/docs/Web/API/DOMParser

A
Anton Shamanov, 2021-03-30
@SilenceOfWinter

$('.container').load('http://localhost:81/ #items');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question