Sunday, June 10, 2007


When opportunities become scarce, and improve already existing wall, and then a technological breakthrough. The breakthrough is AJAX (Asynchronous JavaScript and XML) approach to building Web user interfaces, so that the entire Web page does not have to be reloaded each time the user makes a change. AJAX is one of the components of DHTML.

What gives us the technology. The development WEB applications seeking to distinguish between client and server, and it comes from the widespread use of templates, such as Smarty and XSLT. The projects are becoming more complex and bind the different technologies become far too expensive for the developer. For example, all formatting styles are made in CSS or XSL files, HTML and XML data stored elsewhere, in the third handler server, database in the fourth. And if even 5-6 years ago almost everywhere could see the interlocking whole in a single file, it would become increasingly rare.

If a more complex projects there is a need for structure and readability of the code. Do not litter code programmer code Imposer and Imposer code-flattening designer, and so on.

The need to be distinguished work. For example, the designer will do its work, its operator, its developer, but no one interfere with each other will not. As a result, each project participant will know soon enough, those with whom he had to work. The group productivity and the quality of the project is more times. That problem has now been successfully resolved by the use of templates, but it also poses some difficulties, as to, say, connect Smarty, it is necessary to connect a software module templates, and clearly linked to the structure of the project. And this is not always possible and requires certain costs. Slightly easier to use XML + XSL bundles, as they provide more opportunities, but the alternative is more. And what if we look in the direction of something radically new that would combine all the best with the possibility that there? Try to JavaScript, which has the ability PHP or Perl, including working with graphics and database, which is much more convenient and practical scalability, and the same kross-platformen.

So what is AJAX? For the first time since moving to Ajax in February opened a year article Jesse James Garrett (Jesse James Garrett), "Rethinking the Web." Ajax is not independent technologies. This idea, which is based on two basic principles.

Using DHTML to the dynamic changes of this page.

Using the XMLHttpRequest to contact the server on the fly.

Using these two approaches to create a much more user-friendly WEB-interfeysy page, where interaction with the user. Using Ajax is the most popular after Google started to use it in their sites like Gmail, Google maps and Google suggest. The creation of these sites has confirmed the effectiveness of this approach.

So more : taking classical model WEB-prilozheniya :

Customers dial a search, address issues of his life, coming into contact with the server, it makes a request. The server performs the calculation in accordance with the request, calls to the database, and so on, after which the data are customers and, if necessary inserted in the templates and processed browser. The result is a page that we see, and that 80% of the population at the WEB called the Internet. This is a classic model, which has already proved himself and earned an honoured place in the sun. This is the simplest model of interaction and consequently the most common. But it is increasingly becoming insufficient. Imagine, on-line game "Ships", which played two hard-resident friend of South Africa and a resident of Japan. As with the model to make their game the most fun? In any case sunken ships will be stored on the server, and that would not verify whether the opponent looked like, need to be updated every time the page and podguschat outdated data. "But people come caching" - and you will say absolutely right, but more is not going to be. Caching only accelerate time interaction with the server, but does not eliminate the need to reload the page. Alternatively, you can put some time itself, but in this case the page will be completely reset.
Now look at the model of interaction AJAX :

The sequence of a client and it will likely not understand what would happen, and the word AJAX will be associated only with the name of the football club. But on the server side, all is not true.
When a server generated page, which will show you, and invite them to his interest sequenced. When informed (though not necessarily) a choice the client, its request will be treated to AJAX module, which will be of interest to all its computing and the server itself. But where is the innovation? The main difference in terms of this method enables us to dynamically access the server and perform actions interest us. For example, we need to appeal to the database and receive data of interest to us then we will use. The data we store in the XML file to be built dynamically, thus :
Create a new object of JavaScript : Then write function uses this facility Tel HTML file write a script that would : The file localhost / xml / checkUserName.php we are processing data from the command line in this case in your q. And by maintaining the structure of XML to store the same file. So we can receive and process data from a database, or something else we need. The server will process only the data that we need to be updated, not the entire page when you restart. Now back to the two friends, lovers sea battle : the emergence of this innovation, we can do the following : to check over every three seconds XML file, the test involves an audit of the database to a new record, that is, made of the opponent. If progress was made, page without rebooting mastering ships, thereby ruining the mood of water battles. This functionality is achieved using simple Javascript and stylesheets. This example is illustrative, but not limited to the use of this technology has much to the point. But it is not so easy. Let us now look at negatives. First, we can transmit data only method GET respectively large amounts of data to be left alone. Данная проблема уже не раз поднималась в разных источниках, но господа, есть ведь Сookies, которые вполне приемлемы в случаях передачи больших данных, чем может вместить в себя GET запрос, а Javascript в свою очередь имеет функции для работы с ними. The second-kross-brauzernost. XMLHttpRequest is not part of a standard (though something similar has been proposed in the specification W3C DOM Level 3 Load and Save). So there are two different methods of the object to call the script code. In Internet Explorer ActiveX object is this : In Mozilla, and Safari it is easier (because there is an object embedded in JavaScript) : All modern browsers support this facility and problems arise only 1.8% of the users (according to data of the company SpyLog), which are very old versions of browsers that do not support this facility.
And finally, security. The shrink further. The main problem is that all the data and source code JavaScript functions can be seen by viewing the source code pages, respectively attacker can see the logic queries in a given set of circumstances necessary to implement a set of commands. This is not a role that we are mere comparison, but what to do in more complex situations, such as authentication, and then send passwords. As noted above, the assistance comes Cookies. The necessary data can be sent through them, just handle them. Take an example where the user will be authenticated using technology which is devoted to art.

Generating pages, we are creating unique values, which then placing variables in the server. And Cookies browser, and then when we get authorization username and password that we need to allocate processing module on the server.
Once the user data and clicked Submit his password entered into Cookies, and the user name is a reference open- example, when the data server in the first place a check of the data. Because the values that we have generated at the beginning of the server and then give them a global server variables and cookies must match, then verify the integrity of data transferred in the event of incompatibility program stops working. If all went well, then retrieved all the necessary data and the necessary calculations and work. This type of protection is fairly simple and effective. But for large projects, it did not come.
When a formulation of a security, better use of more sophisticated and reliable solutions. But in most cases, these precautions will be more than enough as the use of more complex modules using a technology that is not always part of the standard software of modern servers, the main feature of which is easy. This is the technology such as MySQL and PHP have become so prevalent because they provide easy work with its low resource consumption and little credibility. And to this software in the best possible approach to the above proposed.
In conclusion I would like to say that AJAX on the one hand, a huge leap in WEB engineering, but on the other hand this is a long standing stage of evolution, which opened new horizons in the field of software development. At the same time, this technology is still "cheese" because of its use at the moment rather pleasant exception. But I am sure that it is not yet time to hear everything.

No comments: