Retrieving Data from the Server

Your RemoteDataStore module can save individual coffee orders to the server. The next thing to do is add a getAll prototype method so that it can retrieve all orders from the server. Get it started in remotedatastore.js:

...
  RemoteDataStore.prototype.add = function (key, val) {
    ...
  };

  RemoteDataStore.prototype.getAll = function () {
    // Code will go here
  };

  App.RemoteDataStore = RemoteDataStore;
  window.App = App;
...

Next you will add a call to jQuery’s $.get method. Like $.post, you will pass it the server URL. But you will not pass it any data, because you are retrieving information instead of saving information. You will need to pass it a function argument so that it knows what to do with the data ...

Get Front-End Web Development: The Big Nerd Ranch Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.