Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6089185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:04:16+00:00 2026-05-23T12:04:16+00:00

TLDR : Can the onreadystatechange event be emulated somehow else for synchronous requests without

  • 0

TLDR: Can the onreadystatechange event be emulated somehow else for synchronous requests without freezing the browser, as it does not get fired in Firefox?

~~~~~

I have created a web form that needs verification and to get some elements from the server before actually being submitted.

What I do now, is that 'onsubmit' I fire an ajax request to my server, send the form details, parse them server side, and return a unique verification number and a md5 hash to the form.

The way it is meant to work is that the form should receive the reply and then proceed to submit the form. I must note that the actual form submission is a normal POST submission without ajax – the form is posted to a server outside my control.

I suppose I need to do a synchronous ajax request – not asynchronous as it is often used for. The point is that the form should never be submitted before getting the reply, simply because it will fail, as the reply contains important fields that the server on the other side will look for.

I tested Chrome and everything seems to work fine with synchronous requests. I do the request, and onreadystatechange I fire the handler to parse the reply.

But Firefox does not fire the onreadystatechange event in synchronous requests. This behavior is there from version 1.5 or something.

What most people do, as I’ve seen, is to run the handler anyway at some point – because the response is received and is in the DOM (responseText), just the onreadystatechange event doesnt get fired.

But this does not work for me: Depending on where on the code I run it, the response may not be available yet, so parsing it will fail.

I’ve tried two solutions, both of them bad:

  • Use a synchronous request, and put the handler on a while loop, waiting for the reply.
  • Use a asynchronous request, and have a while(myvariable); to wait until the reply gets there (myvariable is the reply I get from the server, after handling the responseText.

Both of these of course cause Firefox to freeze for quite some time, as Javascript waits in a while loop. In the end it works fine, if the anti-freeze protections of Firefox don’t kick in and say that a script on this page is not responding.

What would you suggest? Can I do a while loop without freezing the browsers? Maybe a polling thingie that doesnt poll every millisecond as the while loop does, but every 1 second lets say, so the script doesn’t freeze?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:04:16+00:00Added an answer on May 23, 2026 at 12:04 pm

    If your request is synchronous, then once the send() call returns the reply is completely available. That’s the whole point of synchronous requests. Why do you need to do any sort of looping at all in that case?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

if (reader.is_lazy()) goto tldr; I have a background thread that does some I/O-intensive background
TLDR I need to change a javascript variable on the same page after clicking
I can't figure out if this is a bug in Firefox or an anomaly
TLDR I have a function that runs on the end of a pan in
TLDR I want to add some dynamic content into an Ext-JS window / popup.
TLDR : I have an Openlayers map with a layer called 'track' I want
TLDR Linking my fresh boost build with Visual Studio (/Mtd) causes boost to throw
TLDR version: Most important issue is, that in a TSP problem, instead of finding
No worries! It looks more complex than it actually is! Just get down to
For a utility I'm working on, the client would like to be able to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.