O'Reilly logo

Node Cookbook Second Edition by David Mark Clements

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Browser-server transmission via AJAX

We can enhance the user's experience by loading new content directly onto the page via AJAX, rather than loading a new page for each content request.

In this recipe, we're going to transfer our serialized data to the browser as the user requests it and then interact with our client-side data. We'll implement a profile viewer in the browser, which retrieves a selected profile in either JSON or XML, outputting the key values or parent-child nodes for that profile.

Getting ready

We're going to continue to work with our profiles.js object module (from the first two recipes of this chapter), so let's copy that into a new folder. For XML delivery, we'll be using xml2js from the Converting an object to XML and back

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required