Pre-acquisition is a mode of obtaining data from the server; The other side of the Ajax solution is sending data to the server. Because you want to avoid page refreshes, this is more important for sending user data. In a traditional Web site or Web application, each click sends a request to the server, so the server always knows the client's behavior. In an AJAX model, when a user interacts with a Web site or application, not every click creates a request.
One solution is to send data to the server every time a user operates, just like a traditional web solution. Therefore, when a user enters a letter, the letter is sent to the server immediately. This process is repeated when you enter each letter. The problem with this approach is that it is possible to create a large number of requests in a very short time, which not only can cause server-side problems, but may also make the user interface slow in the process of sending and processing each request. Submitting throttling (submission throttling) design pattern is another way to solve this problem.
With the submit throttling mode, data sent to the server side can be stored in the client's cache and then sent at a predetermined time. The famous Google suggest is one such example. Instead of sending a request when each character is entered, it waits for a specific time before sending all the current characters in the text box to the server at once. The processing process from input to send is refined so that the user does not feel the delay at all. Submission throttling has increased the speed of Google suggest to some extent.
The commit throttling is usually either when the Web site or application is first loaded, or when a specific user action occurs. Shortly thereafter, a client-side function is invoked to buffer the data. Always check the user's status to see if it is in an idle (idle) state (to avoid conflict with the user interface). If the user is still working, continue to collect the data. When the user is idle, it means that he is no longer performing the operation, and it is time to decide whether to send the data. The method determined depends on the specific usage scenario, or the amount of data that you want to collect to send, or whenever the user is idle. After the data is sent, the application typically continues to collect data until it receives a response from the server or some user action aborts the data collection process. Figure 3-2 depicts this process.
Figure 3-2
The commit throttling mode is generally never used for mission-critical data. If the number must be delivered to the server within a specific time range, it is best to use a traditional form to ensure accurate and timely delivery of information.