DEV Community

BigSpaces
BigSpaces

Posted on

XHR and a simple story

Be forewarned. This is not a technical document...

Alas, if you want to have a nice little pause from the daily grind, have a listen to Nils and read on:

It was a mere 48 hours ago I did not know what XHR stood for (XMLHttpRequest, for those of you in the same spot I was).

It is surprising to know that a fish can go a lifetime without hearing about water. Yours truly can be programming in Phoenix and using Dev.to without knowing that absolutely everything that happens between my web browser and the server is mediated by this XHR thing.

I'll save you the Google Search: "The XMLHttpRequest Standard defines an API that provides scripted client functionality for transferring data between a client and a server."

And from your faithful Wikipedia: "XMLHttpRequest (XHR) is an API in the form of an object whose methods transfer data between a web browser and a web server. The object is provided by the browser's JavaScript environment. Particularly, retrieval of data from XHR for the purpose of continually modifying a loaded web page is the underlying concept of Ajax design. Despite the name, XHR can be used with protocols other than HTTP and data can be in the form of not only XML, but also JSON, HTML or plain text."

You may be tempted to think, as I initially did, that it was just one more concept in a long list of things I still do not know.

One of my mentors insists that I get really good at the fundamentals, at what is happening under the hood, both conceptually and technologically. So much so, he unpacked the basics of XHR by virtue of helping me create an XHR object from the browser's console, and using it to make a request to an API.

Truth be told, I was still just merely grasping the basics: "ok, javascript object that makes requests and stores responses from the server. Ok, abstract thing that always happens under the hood in a web scenario, no matter if you are using Ruby or Phoenix or what-have-you".

I understood this was at the core of every web experience I ever had, but did not connect how that could be of utmost importance to me.

The following day my classmates and I got the chance to spend some time with Dave Lucia, and we asked him about his interview process when he selects junior developers (hungry for work, we are).

I kid you not. The following words came out of his mouth: "I may ask you to tell me what happens at the level of the browser for each web request. I want to know you understand the fundamentals of what is really going on if you are going to program on top of it"

Jaw drops. And suddenly I am very interested in XHR! Fundamentals. Fundamentals. Fundamentals.

BigSpaces

git add .
git commit -m "Do, a dear, a female dear. Re, a drop of golden sun..."
Enter fullscreen mode Exit fullscreen mode

Top comments (0)