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

187
Views
javascript XHR dentro del bucle negro otras llamadas

Estoy atascado en este problema. el bucle contiene todas las demás llamadas ajax. A continuación se muestra cómo se ve el código

 class SomeClass{ caseFiles() { const self = this; const fileListElms = document.getElementsByClassName( 'summary-file-list' ); if ( fileListElms ) { let html = `<li class="list-inline-item fw-bold"> DOCUMENTS: </li>`; var xhr = [], i; for ( i = 0; i < fileListElms.length; i++ ) { const elm = fileListElms[ i ]; ( function ( i ) { xhr[ i ] = new XMLHttpRequest(); xhr[ i ].responseType = 'json'; xhr[ i ].open( "GET", elm.dataset.url, true ); xhr[ i ].setRequestHeader( 'X-Requested-With', 'XMLHttpRequest' ); xhr[ i ].onreadystatechange = function () { if ( xhr[ i ].readyState === 4 && xhr[ i ].status === 200 ) { console.log( 'Response from request ' + i ); console.log( xhr[ i ].response ); } }; xhr[ i ].send(); } )( i ); } } } } ( () => { const sc = new SomeClass(); sc.caseFiles(); } )();

Mientras se procesa el código anterior, si envío cualquier otra llamada ajax al servidor, esa solicitud simplemente espera a que finalicen todas las llamadas en bucle. por favor avise

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