The role of alert in JavaScript scripts is simply to bring up a modal warning dialog box on the webpage form. In most cases, it is used to verify the validity of the client input when the form is submitted. If the information entered by the user does not meet the conditions, alert will be used to remind the user of the information.
There is no dispute over the use of alert under normal circumstances. It can be said that alert is still helpful. However, will alert cause pressure on the server in case of disputes. No? Maybe most of them see the first response here.
No one else has the reason: the client script is executed on the client. How can it put pressure on the server? There is no problem with this explanation. However, since alert is popped up in the form of a modal mode, I have raised this question. I hope you will discuss it.
In this case, when the server returns data to the client, it contains alert. That is, the following mode:
< Html >
< Body Ms_positioning = "Gridlayout" >
A
< Script > Alert ("EE"); </ Script >
B
</ Body >
</ Html >
In this case, the user can see that the alert warning box is displayed after the page displays a. If the user does not close the alert dialog box, the page will not continue to display B.
This is where the problem occurs: In web development, alert appears in this way (sometimes developers will prompt that the user information is saved correctly or fails ). Will it cause excessive load on the server?
Those who are sure to cause too much load on the server also have reasons to explain. Alert appears as a modal form. In the browser processing process, the thread will temporarily process the waiting state when encountering a modal form, until the modal form is canceled.
In this case, if alert is not closed as a modal form during the Web request process, the current thread of the browser will also be in the waiting state, the connection between the browser and the server will be delayed. If this is the case, it will put a lot of pressure on the server.
I conducted a simple test on this. I assume that the browser will be in the waiting state in the Alert state. I want to use itCodeTest
Private Void Page_load ( Object Sender, system. eventargs E)
{
This . Page. response. Write (system. datetime. Now. ticks + " | \ N " );
This . Page. response. Write ( " <SCRIPT> alert (\ " EE \ " ); </SCRIPT> " );
This . Page. response. Write (system. datetime. Now. ticks + " | \ N " );
}
The test is conducted in. net, but the server time between alert and the response time after alert are judged simply. If the browser is waiting, there is a significant difference between the two. The value increases as alert is disabled.
But the result I tested is two equal. How long does Bu Lun wait to close alert.
I guess from the test that alert will not cause too much load on the server, because the browser processes remote data requests and data display in separate threads during Web requests. Therefore, even if the alert mode displays the display thread in the waiting state, this does not affect remote data requests.
Of course, my tests are a bit one-sided, such as failing to monitor the status of the server at the time and insufficient testing data volume. However, I only want to analyze this issue from the perspective and hope you can discuss it together.