In the MVC project, when you click on submit , a POST occurs, so that the user did not press anything while saving the data, a document.write screensaver containing a <div> screensaver was made: "Blah blah, keep waiting" .

In all browsers, everything works out the rules, there is a post, during the post saver, and how everything is preserved - the page is updated and document.write disappears.

The problem is that in Firefox, when the splash screen appears, when you click on submit , the post does not occur and the program just hangs endlessly spinning the splash screen. As soon as I remove the screensaver from the code, everything works and the post happens.

Help solve the problem, what's the error: in Firefox itself or document.write ? and what alternative can replace ???

  • In general, document.write is not recommended for use. In any case, it is better to add a minimal reproducible example . And you should not roll back the corrected formatting - Grundy

1 answer 1

The appearance of the "screen saver" is best implemented through styles. Make a prepared container on the page:

 <div id="saving-dialog" style="display: none"> ... </div> 

To show change his style:

 document.getElementById("saving-dialog").style.display = "block"; 

Advantages compared to document.write - the sea:

  1. Layout is among the other layout. No need to push HTML tags inside string literals;

  2. In order to see the message on the page during the layout process - it is enough to change the style from the developer’s tools in the browser, there is no need to resort to clever tricks;

  3. When displaying such a prepared dialog, the browser does not need to re-parse the page;

  4. The outdated method is not used;

  5. This method does not exactly kill the submit form.