Asynchronously load the contents of a div

You mean as a plain string? This could be done with a DOM parser as shown above…

PS: Here’s how you could do this with vanillaJS:

var xhr = new XMLHttpRequest()

xhr.addEventListener('load', function () {
  var parser = new DOMParser()

  var doc = parser.parseFromString(
    xhr.responseText, 
    'text/html'
  )

  var articles = doc.querySelectorAll('.article-loop')

  // etc.
}.bind(this))    

xhr.open('GET', 'content.html')
xhr.send()
1 Like