Ajax Application Scenarios
1. Form-driven interaction
Traditional form submission, after the text box input, click the button, the background processing finished, the page refresh, and then look back to check whether the refresh result is correct. Using AJAX, after clicking on the Sunmit button, immediately asynchronous processing, and on the page quickly show the results of the update, there is no overall page refresh problem.
2. Deep-rooted tree navigation
The Deep cascading menu (tree) traversal is a very complex task, using JavaScript to control the display logic, using AJAX to delay loading deeper data can effectively reduce the burden on the server.
Most of our previous processing of cascading menus is this:
In order to avoid the overloaded pages that are caused by each operation on the menu, instead of using each call back to the background, all the data for the cascading menu is read out and written to the array, and then the rendering of the subset item is controlled by JavaScript according to the user's action, which solves the response speed, Do not overload the page and avoid sending requests frequently to the server. However, if the user does not operate the menu or only a part of the menu, the read data will become redundant data and waste the user's resources, especially in the context of complex menu structure, the large amount of data (such as the menu has many levels , every level of food and hundreds of projects), this abuse is more prominent.
If Ajax is applied in this case, the results will be improved:
When we initialize the page, we only read all the data from its first level and show that when a user operates one of the first-level menus, all data for the level Two submenu to which the current level of the project belongs is requested by Ajax to the back desk, and if you continue to request an item from the level two menu that is already rendered, And then to request all the data of all level three menus for the two-level menu item that you are working on, and so on ... In this way, take what you use, take as much as you can, there will be no data redundancy and waste, reduce the total number of data downloads, and update the page without overloading the entire content, only update the part that needs to be updated, relative to the background processing and overloading of the way to shorten the user waiting time, but also to minimize the waste of resources.
3. Fast communication between users and users
The most frustrating thing about being involved in the conversation is to have the user refresh the page over and over again to see if there is a new discussion. New responses should be displayed as quickly as possible, and Ajax is the best choice to free users from distracting refreshes.
4. Similar to voting, yes/no and other innocuous scenes
In a scenario like this, if the commit process needs to reach 40 seconds, many users will simply ignore the past and not participate, but Ajax can control the time within 1 seconds, so that more users will join in.