0

new to working with AJAX functions. I've ran into the following code in research in the frontend of an example allowing for messaging between users (this is from an online book on Node.js).

The below code gives the frontend for an application allowing for user messaging. What's important is that we're trying to create a long poll channel of communication between the client and the server.

// Client code
var counter = 0;
var poll = function() {
  $.getJSON('/poll/'+counter, function(response) {
     counter = response.count;
     var elem = $('#output');
     elem.text(elem.text() + response.append);
     poll();
  });
}
poll();

My question - what's the meaning of $ here? It's used in a couple of different cases, firstly in $.getJSON and later in $('#output') and I'm not sure what it means in either of the cases. Any insight in either case is really appreciated.

Some research on ajax functions. I see their functionality but not the specifics of the syntax, particularly in that it feels like $ is used in different ways across the code.

Thornside
  • 11
  • 2

0 Answers0