Now you can observe that the use and application of new technologies is gaining popularity on the Internet. One of them is AJAX. What it is? What characteristics does it have? Where is it used? All these questions can be answered within the framework of this article.
general information
How is AJAX decrypted? What does it mean? This abbreviation is an abbreviation. It stands for Asynchronous Javascript and XML ("Asynchronous Javascript and IKSML"). Often you can see or hear information that this is a new technology. But it is not so. The fact is that Javascript and XML have been around for quite some time, while Ajax is a synthesis of these technologies. Most often, it is used in conjunction with the term Web 2.0 and is implied as the use of advanced development methods.And what is the feature?
, , AJAX. ? ? - , . . ( ), ( , ). , , . , . Javascript , . AJAX. , ? . – , .
Benefits of Ajax
This technology offers two methods by which a web page can be implemented. The first involves making changes without rebooting. This can be done using dynamic server calls. The second involves the use of individual technologies, the most popular of which is XMLHttpRequest. Regarding the very advantages of Ajax, the following can be said:- You can create a convenient web application in which the interface will have a number of features that are pleasant for the user, which ultimately will facilitate the interaction of the person and the site.
- Instead of a full page reload, a partial one occurs. This saves machine resources and optimizes performance.
- The server part of the site actively interacts with the user.
- .
, , , . ? «» . XMLHttpRequest. . , . AJAX PHP. GET- POST-. URL. , , . AJAX- ? POST. , , .
How does asynchronous Javascript and XML function in practice? Let's figure it out with an example. Regarding the structure of the building, it is necessary to ensure that the client part provides all the necessary functionality for the safe exchange of data. It should provide the necessary methods for transmitting information in selected ways. The server part should provide processing of the received data, and, already based on it, generate new information in order to subsequently transfer it to the client. The most common interaction of this type is working with a database. We have already mentioned such an element of many business sites as the feedback form. The advantage of Ajax in this case is that it carries out asynchronous data transfer. In other words, while the information is being sent,the user can perform all the necessary actions. Focusing on the specifics of each particular case, it is necessary to decide whether it is necessary to inform the site visitor about this process. Regarding the same form of feedback, it should be said that in this case we can write "the operator is picking up an answer", or something similar.
XML, - . , JSON. . XML, , AJAX- . (X)HTML. JSON, , Javascript.It is necessary to exercise caution and take into account the fact that many attackers like to transmit malicious code through this technology. Therefore, it is necessary to provide a procedure for checking the received data before processing it. Implementation features for different browsers may vary slightly, but, in general, the scheme of action is the same here.
Making a request to the server and processing the response
The whole sequence of actions will look like this:- Initially, you need to create and make sure that XMLHttpRequest exists.
- Then the connection to the server is initialized.
- We send a request to him.
- We wait until the data arrives and process it.
. , . , - . . – . , XML DOM- HTML. JSON-? , Javascript. ? JSON . , , . , , .
Server programming languages
Almost any web application uses them to one degree or another. The most popular for data transfer is PHP. It usually writes files for sites where the speed of information transfer is not critical, but a balance between it and reliability is preferred. XMLHttpRequest submission methods have been discussed above.
Configure the server
What programs are needed for AJAX to work fully? What will it give us? What are they needed for? To get answers to these questions, you should familiarize yourself with the following list:- HTML / XHTML. They are needed so that the server recognizes the page layout.
- CSS This tool is necessary for the visual selection of page design.
- DOM. , .
- XML. .
- JavaScript. "" .
- XMLHttpRequest. , .
, , , AJAX. . , "". , . , . , , JavaScript . , - - . . XML-.
It is necessary to work out its structure. But what if parameters that are objects are passed? In this case, it is necessary to provide for the creation of a variable, where there will be a link not to it, in case of a call from the function. To be able to access it from anywhere in the code, you need to make it global. For convenience, it is advisable to use a database management system. Of course, this is not necessary. But still, using a DBMS will allow working with data more conveniently and efficiently.We are working on the engine
? , , . GET POST-, . , URL . XMLHttpRequest-. . , . «» ( , ) , . . - . , , . , , – . . , 16 . , , .
When using Ajax to create an interface for a page or application, it is necessary to make sure that the result works well both on different operating systems and on different browsers. In the first case, emulators can provide invaluable help. In the second case, it will be enough just to install various programs and check the functionality of the code on them. It is also necessary to provide certain actions in case the browsers used by the user become obsolete or he disables the necessary settings. In such cases, care should be taken to display text on the page that indicates the reason why viewing the site in this case is not possible. Yes, now the vast majority of people use modern technology, but do not completely ignore the probability ofthat a few percent of visitors will use somewhat outdated software. And on a business scale, this can have significant consequences.. "" , , . , , , . , , . , , . – "".