Chapter 20. XHR: loading data

This chapter covers

  • Loading data with the XMLHttpRequest object
  • Calling functions once the data loads
  • Updating views with loaded data
  • JavaScript Object Notation (JSON)
  • Converting JSON text into JavaScript objects

A calendar or movies database or adventure game can use a lot of data. A news site may have up-to-the-minute updates with breaking news and sports scores. It’s not always desirable to load all of the data at once or for a visitor to have to keep refreshing a web page to get the latest information. It would be great if a page could access just the pieces of new data it needs to stay fresh, even after it has loaded. Stock prices, tweets, comments, scores, and, yes, the current health of zombies can ...

Get Get Programming with JavaScript now with O’Reilly online learning.

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