Chapter 3
Pattern Design describes how a program solves all common problems. As a matter of fact, there are already solutions. using existing design patterns to solve the problem will reduce the development time.
Ajax also has many design patterns to solve specific problems. For example, it is the hidden frame technology, asynchronous XMLHTTP request, which uses the communication mode between the client and the server using JavaScript.
Michael mahemoff recorded these patterns, his
Githubhttps: // github.com/mahemoff
Home page: http://mahemoff.com /.
Ajax design patterns (Michael mahemoff)
Each design pattern is not fixed and simple to apply, which means that developers concentrate on each pattern and design a suitable scheme to correspond to their own application functions.
Communication Control Mode: javascript can be used to communicate with the server. The question is, when is the best time for a client to send a request to the server? In some cases, information is pre-loaded from the server and can be provided to the user immediately during user operations. In other cases, you may want to send and receive data to the server at a certain interval. Or, not all things are loaded at a time, but in a certain order. Ajax provides a good interval to control the communication between the server and the client to achieve the desired effect.
Prediction data acquisition mode: assume that you use ajax to pre-load data in the next step. For example, if you are reading a 3-page article and when you are reading the first page, you can load the second page after several seconds, so that you can provide data immediately when you press the second page. Another example is email. When a user writes an email, the user's address book can be preloaded, and a prompt message is provided when the user inputs the address. Both Gmail and AOL webmail in the email system use this mode. When this mode is used, there is a logical prediction, and the information provided can help the user complete the next step.