Ajax is a "way" to use < in> XmlHttpRequest , which is not a language, but rather a Javascript API , as well as File API , DOM API , etc.
What XHR ( XmlHttpRequest API ) does is a client and server communication, not to say that it is asynchronous, since Ajax is the way to use XHR "asynchronously".
Synchronous XHR example (this is not Ajax):
var oReq = new XMLHttpRequest();
//Defina como false
oReq.open("GET", "/url", false);
//Espera completar a requisição, geralmente congela o browser
oReq.send(null);
alert(oReq.responseText);
Asynchronous XHR (ie Ajax) example:
var oReq = new XMLHttpRequest();
//Defina como true
oReq.open("GET", "/url", true);
//Função assíncrona que aguarda a resposta
oReq.onreadystatechange = function()
{
if (oReq.readyState === 4) {
alert(oReq.responseText);
}
};
//Envia a requisição, mas a resposta fica sendo aguardada em Background
oReq.send(null);
Then Ajax means A synchronous J avaScript a nd X ML which translating is Javascript and XML asynchronous) and is the way to use the XHR that makes it Ajax or not. The term Ajax would be a nickname for the XHR used asynchronously.
It is important to note that synchronous mode has been nicknamed SJAX, meaning and J strong> nd X ML (synchronous Javascript and XML)), but note also that SJAX is out of use and modern browsers have started issuing Warnings on the console and will probably come to "block" this way, however within Web Workers because it runs in a separate thread, just as the error message says:
Synchronous xmlhttprequest on the main thread is deprecated
So in the main thread , which refers to the main thread running on the tab, the Web Works runs on sub-threads, which causes no problem, and in this case it is not in disuse.
More details on link
Another situation is that we do not always use XML, but at the time the nickname came up it was heavily used for supporting .resposeXML
of XHR, to use Json today we have to do parse
of .responseText
.