AJAX is not a programming language. So what is it?

Asked

Viewed 2,300 times

40

I’m asking this question because I’m tired of seeing things as requirements for a certain programming position:

You need to know the languages PHP, Javascript, CSS and AJAX

I have learned that AJAX is not a programming language (of course, because no one "program in AJAX").

But when it comes to the question of terms, how should we classify AJAX? Resource? Technology? How should it be termed?

  • 1

    The passage quoted is from a job vacancy?

  • 1

    @rray as always, the job vacancy ads always mitando.

  • What is the right one then? "It is necessary to know how to type in Ajax" or "It is necessary to know the libraries Ajax, jQuery..."...

  • 3

    @Zoom I would say that AJAX is a technique. To use this technique, you need to know the Xmlhttprequest API, Javascript and DOM, and also the concept of searching for information in the background, asynchronously, and updating only parts of the page without having to reload the entire page. There are also frameworks that abstract the way to use Ajax (using Java JSF, for example, you use Ajax by writing only Facelets tags, without having to write Javascript or interact directly with Xmlhttprequest and DOM).

  • @Caffe is right, it is absolutely right, it is a technique or way to use Xmlhttprequest!

  • I believe that the term AJAX is what is today called SPA (Single Page Application). I understand so when I see as a requirement "AJAX programming", IE, that it will be necessary to know how to program a system that uses a lot of JS, and not just server-side language with constant refreshes.

  • 1

    @lucasDotWith I think you’re confusing, ajax doesn’t need to be used to load a page or refresh a page, it’s used for functions like fetching notifications, messaging chats and sending data, but that doesn’t mean the whole site is going to be based on Ajax, often we use it only on a specific feature. What we can say is that the SPA makes use of Ajax, but not the other way around.

  • William. I didn’t really mean it. When I see "AJAX Programming" as a requirement, I imagine it’s not just to make a request to search for a notification, to search for a message, a Long Polling or a request triggered by an event. Yes, this is AJAX, but I referred to it as a vacancy requirement and not as a concept. A SPA is much more complex than just a simple request. Anyway, it seems a little confusing, because I ended up not expressing myself right.

  • 4
Show 4 more comments

6 answers

47


The AJAX is a "way" of using the Xmlhttprequest, which is not a language, but a API of Javascript, as well as File API, DOM API, etc..

What the XHR (Xmlhttprequest API) does is a client and server communication, does not mean that it is asynchronous, whereas AJAX is the way to use XHR "asynchronously".

Example of synchronous XHR (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);

Example of asynchronous XHR (this is AJAX):

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);

So Ajax means Tosynchronous JavaScript tond XML (translating is asynchronous Javascript and XML) and is the way to use 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 the synchronous mode was "nicknamed" SJAX, which means Synchronous JavaScript tond XML (Javascript and synchronous XML)), but also note that SJAX is out of use and modern browsers have begun to emit warnings on the console and will probably come to "block" this way, however within Web Workers, as it runs on a separate "thread" as well as the error message states:

synchronous xmlhttprequest on the main thread is deprecated

In other words, only in main thread, which refers to the main thread running on the tab, the Web Works perform on sub-threads, which causes no problem and in this case is not in disuse.

More details on https://xhr.spec.whatwg.org/#Sync-Warning

Another situation is that we don’t always use XML, but at the time the nickname came up it was quite used to have support for .resposeXML XHR, to use JSON today we can do the parse of .responseText with something like:

var resposta = JSON.parse(oReq.responseText);

console.log(resposta);

Or you can adjust the property XMLHttpRequest.responseType to "json" and use XMLHttpRequest.response to get JSON, assuming the server response is actually JSON, leaving something like:

oReq.responseType = "json";

var resposta = oReq.response;

console.log(oReq.response);

Javascript/Ecmascript asynchronous and callback

To understand a little better about how callbacks run, read on:

  • 7

    Take a insta-up ™ for the good complement. + 1

  • In fact it means then that the protagonist is the XHR API, so AJAX is just a term used by someone, who in a way made more known the term abstracted than the XHR technology itself, kind of right? Or is there something in AJAX that can be used without XHR ? @rray

  • @Magichat Ajax is this, using XHR asynchronously, anything else without xhr is not Ajax ;)

25

  • 1

    I wouldn’t say "set of technologies" because basically you need Javascript, DOM and the Xmlhttprequest API, being that the first two are common components of the web and are also present where Ajax is not.

  • @Caffé thanks for the comment, I edited the reply has more suggestions, is in agreement now?

  • Seems right to me.

  • @Caffé was worth the return, it costs nothing to give a reformulated :)

  • The link to the article is broken. :/

18

To implement the Exchange web interface (OWA) without using page exchange to load new content, Microsoft created an interface in its MSXML component that allowed sending a request over HTTP and receiving an asynchronous response. At the time what was bombarding was XML and the interface was named Xmlhttprequest, but it does not require in any way that the returned content is XML.

Other browser developers adopted the interface and it exploded when Google launched Google Maps. Later it was packaged in Jquery which greatly facilitated its use portability between browsers.

So, to answer the question, I think AJAX is best qualified as a technique than as a technology. It’s certainly not a programming language. The technology would be the interface for asynchronous requests, which browsers originally did not support.

The complete story is in Wikipedia, as usual.

  • 8

    I definitely did not understand how they denied that answer.

  • 1

    I did not give the -1, but the historical part can be better clarified. Xmlhttprequest was adopted as the default, but early AJAX implementations used IFRAME for data exchange: https://en.wikipedia.org/wiki/Ajax_(Programming)

  • 3

    @lbotinelly ah ah, you can improve a bit. But I find strange the negative, pq besides responding, already gave a contextualized. I would understand the person not vote, but the fact of negative left me curious to understand the reason.

  • 6

    @Bacco the downvoters bark, the caravan passes. =)

  • 3

    +1 per "technique"

14

AJAX (in English Tosynchronous JavaScript and XML, or Javascript and asynchronous XML) is a term used for asynchronous communication practices between a web application and a corresponding back-end.

In this definition, AJAX is a protocol (in the sense that it defines a behavior for data exchange), its implementation a canal (where requests are made and responses received) and their use a practising (asynchronous requests and their treatment).

14

The Question Being More Specific:

AJAX is a Recourse javascript.

In which you can :

  • Refresh the web page without reloading the page
  • Send data to a server - after the page is already loaded.
  • Receiving data from a server - after the page is already loaded.

5

It is a method or process for using Javascript and XML (or JSON) in communicating pages with users.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.