Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

356
Vistas
Function on XMLHttpRequest.upload progress event not firing on Safari/Firefox (works on Chrome)

I have a form on a Prestashop's website where users can upload files. Those files can be heavy sometimes so i needed a progress bar with a percentage displaying in real time.

I did it with the <progress> tag and the XMLHttpRequest object.

Everything's working fine on Chrome but nothing happens in Safari and Firefox.

Here's the javascript code :

function uploadFile(event){
        const xhr = new XMLHttpRequest()

        xhr.open(
            'POST',
            event.currentTarget.getAttribute('action')
        )

        xhr.upload.addEventListener(
            'progress',
            fillProgressBar
        )

        xhr.send(new FormData(event.currentTarget))
    }

    const progressElement = document.body.querySelector('progress')
    const progressInformation = document.body.querySelector('#progress_information')

    function fillProgressBar({lengthComputable, loaded, total}){
        const progression = lengthComputable ? ((loaded / total) * 100).toFixed(0) : 0
        progressInformation.textContent = progression
        progressElement.value = progression
        
    }

    const customForm = document.body.querySelector('#custom_form');

    customForm.addEventListener(
        'submit',
        uploadFile
    )

When i test a console.log('Hello') in :

xhr.upload.addEventListener(
    'progress',
    console.log('Hello')
    fillProgressBar
)

I can see it in the console, the problem is the function fillProgressBarwho just never fires.

I have searched a lot on the Internet in vain...

What can I do on this one fellas ?

Thanks for reading !

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda