ajax|web| Design
Javascript:void (0); >ajax Most commendable is the asynchronous interaction, not the absence of refreshing
Many people are optimistic about javascript:void (0); >ajax without refreshing technology, so as to identify with javascript:void (0); >ajax is used to do without refreshing. This realization is wrong, what is no refresh? No refresh is the page without overloading, what is asynchronous interaction? Asynchronous interaction is a simple multi-threaded, when you read the article in a blog, but also can use Javascript:void (0); >ajax do not refresh the reply to submit, it seems that although there is no refresh, but the most important here is asynchronous, that is, you can read the article, while you can submit to the server your reply information, using good this asynchronous, can be regarded as mastering the javascript:void (0); The essence of >ajax. Many occasions, no refresh is presented to the user's visual experience, and asynchronous interaction is unknown to the work after the stage, this situation led to most people's error understanding javascript:void (0); >ajax the weight of the score.
Second, the recommended lightweight application on the Web javascript:void (0); >ajax
The famous Image Store websiteFlickrUsing JavaScript: void (0); >ajax is superb. The reason I'm saying this is because I think Flickr knows the JavaScript: void (0); >ajax the pros and cons, and firmly grasp the features of their website, and not because of JavaScript: void (0); >ajax and JavaScript: void (0); >ajax, instead of being driven by technology, lets JavaScript: void (0); >ajax in the Web site, for the site provides a better functional services. As with Flickr, whether it's on a multiple-map list page or a Dantu detail page, the title and description of the modified picture are applied to JavaScript: void (0); >ajax technology, so that users do not have to jump to a separate edit page, edit, click to save, also use asynchronous interactive way to submit data, at this time, the page display a loading characters, other parts are not affected by any, is too intimate service.
Another example based on the tag of Professional blog Search service provider Technorati also used javascript:void (0); >ajax, in search of a tag, the main page will immediately display all Technorati database query data entries, on the left side of the sidebar will display two loading icons, after a while, the two loading will show specific content, The link to this tag-related Flickr image and bookmark Service site (furl&del.icio.us) is shown, because these two parts are taken from other sites, if the server unified first to get the data together to display to the page, will be affected by the speed of the network slowed down, Through the javascript:void (0); >ajax asynchronous interactive way to first immediately display local data, and then by the client and Flickr, Furl, del.icio.us deal with their data, that is, save the flow of bandwidth without affecting the user access speed, it is smart.
Through the above two successful applications abroad javascript:void (0); >ajax's website, we found that they are all using lightweight javascript:void (0); >ajax, is that kind of interaction simple, less data operation. This is also in accordance with javascript:void (0); >ajax's original intention, although like www.backbase.com and bindows are in the RIA has the astonishing performance ability, but the speed is slow, the search engine support is not good , Difficult to develop and other problems can not be satisfied with the user, please remember: javascript:void (0); The ultimate goal of >ajax is to improve the user experience and to facilitate user interaction, rather than technology.
Iii. javascript:void (0); MVC Architecture Design of >ajax
Many people think that the application of javascript:void in the mature framework (0); >ajax destroys the integrity of the framework, and it is more common to say that there is a three-tier architecture that destroys the MVC pattern in a Web application. The theory of MVC I don't say much, the classic three layers, five lines are familiar to all, in the Web application, because the browser/server inherent in this request/response of the disconnected network communication mode, determines the model layer can not implement the initiative to the view layer to send data update events, So the classic MVC theory is modified in the common mature MVC framework: The control layer is notified by the model layer after the business is processed, and then the control layer assumes the obligation to send data updates to the view. But javascript:void (0); " >ajax is born with a listening function, javascript:void (0); >ajax the onReadyStateChange event that implements an asynchronous response has the ability to listen to events in the client program. Now want to, use Javascript:void (0); " The MVC model implemented by >ajax has the following diagram:
The idealized design looks like this:
- Three-layer corresponding file objects: view.jsp (view), Action.do (Controller), Model.java (model)
- View.jsp is the user sees the interface and passes the built-in javascript:void (0); >ajax object asynchronously sends a request to Action.do, javascript:void (0); " >ajax. onReadyStateChange started listening.
- Action.do receives a request from view.jsp (get or post) and sends it to the corresponding business/data model after the request is made Model.java
- Model.java begins to perform business operations, executed directly to the view.jsp page to send a notification of data updates, this notification message may be XML encapsulated data, there may be a piece of text, or even a section of HTML code, of course, since with MVC, do not recommend a model to send HTML, recommend or use XM L encapsulates business data.
- view.jsp page javascript:void (0); " The onreadystatechange of the >ajax object receives the data update notification, and makes the page rendering update with DOM according to the actual situation.
Through the steps above, a typical three-tier interaction based on MVC is done coherent. Of course, users who are familiar with the MVC framework under the web, such as Java developers familiar with struts, may not be accustomed to sending a data update notification directly to the view by the model layer, so we can also change the model layer business process to send the update notification first to control, The control to inform view can also be.<