Ajax has been hot for more than two or three years, and it has revolutionized the web and is no doubt about the unprecedented experience it brings to the user.
While Ajax can bring a lot of benefits to Web applications, the use of AJAX applications is still a matter of serious consideration and should never be misused.
First, a few old questions:
Second, the user's habitual, many user habits and the use of traditional ways to interact with the server, although they may be tired, but the habit is a habit, suddenly appear a new way when it will let them know the wrong. Ajax does not need to refresh the browser, so in many cases the user performs an operation to find that the browser does not have any movement will feel very confused, especially when the network speed is slow, a user's request takes a long time to respond, during the waiting period, Users may think that the web has a problem shutting down the browser or doing something else. In addition, users will be accustomed to some of the features provided by the browser, for example, forward, back, refresh, stop, these features are often used by users, and when the use of Ajax will lead to the failure of these functions, of course, now a lot of people have written a solution, there are many of these solutions online.
Another issue that needs to be noted is the impact on the performance of the server.
Ajax asynchronous request, this method will bring a new problem. In the traditional way, for a user, each request to the server requires a response from the server before it can make another request to the server, so that subsequent requests are processed after the last request has been executed. But with Ajax breaking this constraint, a user can execute multiple requests quickly and continuously, which in contrast to the traditional way, raises higher requirements for the server and poses a greater challenge to the programmer. Usually, you should try to avoid this situation, for example, Sina's comment page, the paging bar adopts the way of asynchronous request, the user drag the cursor can be easily directed to the required paging, but in the process of dragging, the cursor every page points to the server to request the appropriate data, If the user drags the cursor to page 10th at a specific speed, then the server will have 9 requests that are redundant, and if the 9 extra requests have the server perform the task of reading the database, this will waste a lot of server resources. If the user finds that the 10th page does not have what he wants, and then moves to page 9th, the server will request the corresponding data, but in fact the server has obtained the same data, if such a thing happens in real life, perhaps you will feel that this is really a lot of waste.
Let's compare the two situations (assuming there are no pages 10 data):
1, produce 3 requests + open 3 times database + each read and transfer 10 data amount of data
2, produce 1 requests + open 1 times database + read 30 data each and transmit
2 less than the situation 1 open 2 database, on the execution of 2 database queries, less than 2 requests, more than 20 rows of query data volume
Obviously, in the 2nd case, the user will wait for less time and the server will do less processing.
This is the new paging method that I put forward to read the data that the user will request more than once, and then page through the client. The user gets more data on the first request and then processes it through the client, so that the user does not need to request the server in the process of Reading page 3rd from page 1th, the first 3 pages are easier to switch, and the server's burden is reduced. The only downside is obviously that the first time a user asks for a little longer, but more than 20 data query volume and the amount of traffic compared to the time saved by the page switch is insignificant, in addition to the Ajax, we can use it to make users feel less than the amount of 20 data processing.
The use of Ajax can bring users a good user experience, but the handling of the bad words will cause the server to bear a greater burden, the same processing good, you can reduce the burden on the server redundant, the specific situation to see how to use.