What is the importance of the request in JavaScript lesson

What is the esence of this lesson in one’s JavaScript learning journey?

A request is made when we communicate with the server. The request is composed on the client and bundled into such a form that the server can unpack and parse. What we get back from the server is called the response. The idea of using XHR is to keep the current page loaded and only swap out certain page elements as apply, or respond to user interaction by updating the display.

When we type into a search bar, for instance, each letter we type results in a new request which is responded to with a list of suggestions. This all happens without the page having to reload. Only when we submit our search request does the page change to the response SERP.

Okay, Thank you.

Is it a concept that should compulsorily be incorporated into one’s every design?

What is it used for specifically?

If a page is static, that is has no interactivity with the server, then the only request(s) are for the page source and the supporting resources, style sheets, images, etc. XHR is used specifically when we wish to update a view in real time without reloading the page. The response is unpacked by JS and inserted into the DOM as refreshed page elements.

Where will these updates or responses come from? Will it be coming from a Database, or from other pages or from where?

Where have these update contents been kept?

Wherever they are stored on the server, be it a database, a folder of snippet files or any type of lookup table. The code on the server side is what handles the request.

Okay! perhaprs, I’m not conversant with using JavaScript with database yet. Hopefully, they will all make sense with time.

We won’t be working with the database from the JavaScript perspective. That is done by server-side programs once our request is parsed for back-end handling. On the front end we compose the information we wish to send with the request, and when the response arrives we compose that into something we can insert into the DOM.

If you are working with APIs and you have access tokens and id hashes then you are given permission to use the resources on the server under this particular license. Just be sure to compose the requests the way the API is equipped to handle them.

We’re not writing APIs here, thankfully. That’s the sort of thing programmers with a good deal of expertise are called upon to do, and what we’re learning and working toward. The task of the API authors is to make the users able to seamlessly use it in their own apps. A bit over our heads, just now but we can still learn to use an API and incorporate it in our work. That much we can learn in the present tense.

Bottom line, become familiar with the local environment, namely the DOM and all its intricacies (just kidding). Get to know it and learn how to traverse it and manipulate it. Without that ability we wouldn’t need AJAX.