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

246
Vistas
Synchronous ajax request in beforeunload event alternative to support Edge chromium

I have to make a synchronous ajax request in beforeunload event, but it is throwing an error as synchronous ajax request are not supported in chromium browsers during page unload events.

What could be the alternative to make a synchronous ajax request during page unload event cycle.

window.on('beforeunload',function(){
    $.ajax({
         url:'@Url.Action("ActionName","ControllerName")',
         async:false,
         data:formData,
         success:function(){
            //Success logic
         },
         error:function(){
           //Failure logic
         }
    });

});

DOMException: Failed to execute 'send' on 'XMLHttpRequest': Failed to load:

Note: navigator.sendBeacon() is asynchronous by default, but i need to have a synchronous request in page dismissal.

Any suggestions?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Synchronous XMLHttpRequest has been deprecated, you can refer to this doc. Blink has removed support for sync XHR from page dismissal events (beforeunload and unload) and you simply can't do that anymore in chromium browsers.

The modern ways are to use sendBeacon and fetch keepalive as workarounds. For more information, you can refer to this tweet and this thread. If you don't use these workarounds, I think there's no other way.

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