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

146
Views
Obtener DOM en ajaxComplete

¿Hay alguna forma de actualizar DOM en ajaxComplete? Puedo obtener y modificar responseJSON, responseText, etc. pero no quiero meterme con el texto y buscar el elemento correcto.

 $(document).ajaxComplete((event, xhr) => { let y = $('a')[0].getElementsByClassName('b')[0]; y.onclick = (event2) => { console.log(event2); return false; }; }

Cuando estoy haciendo lo anterior, no está adjuntando el evento al nuevo elemento DOM recuperado, sino al anterior, supongo.

Quiero adjuntar el evento al nuevo elemento DOM recuperado.

EDITAR:
He intentado usar este objeto de evento y $ pero todas estas variables están relacionadas con el DOM 'antiguo'

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Parece que estás usando jQuery. jQuery tiene un asistente ajax sofisticado.

 $.ajax({ url : "/api/get/user" // User Ajax endpoint, method : "GET", // your Ajax method . post, get put data : // data you want to sent to the backend }).fail(function() { // If Ajax failed then do this }).done(function(data) { // If Ajax success then do this });

En el caso del usuario, lo que hago, llamaré a mis funciones (en su caso, tal vez ajaxComplete ) dentro de .done()

y voy a reemplazar

 let y = $('a')[0].getElementsByClassName('b')[0];

por

 let y = $('a').find('b'); // or dynamic class or id

lápiz de código: https://codepen.io/umanda/pen/abwboqp

about 4 years ago · Juan Pablo Isaza Report
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!