The key to sending JSON in response to an Ajax request is to use whatever language’s
version of the JSON.stringify() method to convert the object into a JSON-formatted
string. In the following Node application, we can use the Node version of JSON to format
the data. The MIME type for the data is also set to application/json: