8

Is it possible to handle a JSON response using plain Ajax (i.e. JavaScript, without JQuery)?

In this description: http://www.w3schools.com/ajax/ajax_xmlhttprequest_response.asp only Text and XML objects are mentioned, but how to handle a JSON respone?

I just want to use pure JavaScript, without any additional libraries.

This shows me the JSON respone:

console.log(xhttp.responseText);
Evgenij Reznik
  • 16,978
  • 34
  • 97
  • 170

1 Answers1

6

You can use JSON.parse():

console.log(JSON.parse(xhttp.responseText));
baao
  • 67,185
  • 15
  • 124
  • 181