如果发生网络错误,重试提交表单的最佳方法

It may happen that a HTML form can be loaded, but cannot be submitted due to a network error (in context of a mobile application). The browser will show an error in this case. Is there a method to hide this error to the user and keep retrying to submit the form?

If the form is using regular submission then you have no control of qhat happens after the user clicks submit. The only way you can keep retrying is by Ajax because you get a response back to your JS code

You could use the onclick event of <input type="button" /> to trigger a function that sends an AJAX request repeatedly until a status of 200 (OK) is received, then redirect the user to the next page. For better or worse, if the browser displays a message in regards to the network connection, that is beyond the control of javascript, HTML, and PHP.