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

240
Views
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 answers
Answer question

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 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!