It helps to think of a callback function somewhat like an interrupt handler. There's nowhere in your in your code that explicitly calls this function. Rather the function gets called when a certain event occurs. In this case when the response comes back from the HTML device to which you have sent a request.
We said that we made a call to the function "getRest(url,cb)". The first parameter is rather simple. It would look something like "http://126.96.36.199/irsend/2/12345/20/". The second parameter "cb" is the callback function.
This function DOES NOT get executed when you call "getRest". It looks like it does but it doesn't. It only gets called when your device acknowledges that it has received the REST command. In this case the function takes the response text returned by your device, converts it into a JSON formatted string and uses the innerText command to display it on your webpage. Each time you click a button on the remote you can see the text that is returned.
For example the webpage might display something like this
The contents of the "data" field was created by the Arduino sketch in the "processIR" function using "client.print()" commands.
Inside the getRest() function is where we do the actual HTML PUT command. The heart of the command is the "XMLHttpRequest()" object which we create in the variable "Request". We use various methods and variables of that object to set up the request and then eventually transmit it. The first variable we set is the "Request.onreadystatechange". Again this variable is a callback function definition. This code does not yet executed where we have defined it. Rather we have created batch of code that will get called every time the ready state of our request changes. Inside this function we check for the ready state to be equal to 4 which means that the request has been completed.
The "Request.open("PUT", url, true)" method tells it that this is a HTML PUT command and passes it the REST URL we want to put. Finally we "Request.send()".
For more information about XMLHttpRequest we suggest the following resource https://www.w3schools.com/xml/xml_http.asp