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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.