Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

133
Views
How can an external JavaScript access html elements output by xmlhttprequest?

Xmlhttprequest I'm returning a html div element from a php file to another php file using xmlhttprequest ajax

I'm outputting the div xhr.responseText with innerhtml. Example

document.querySelector('div.users').innerHtml = xhr.responseText;

Which is working fine.

The problem is that the response gotten is not accessible by an external JavaScript

Example. The response is like this. <div class="me">hello world</div>

When I use an external JavaScript to get the the elements. Nothing works. Example

document.querySelector('.me').addEventListener("click", () =>{console.log("hi");});

Nothing happens when the element is clicked.

Any solution please? ๐Ÿ™

about 4 years ago ยท Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
ยฉ 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!