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
  • 17,916
  • 39
  • 104
  • 181

1 Answers1

6

You can use JSON.parse():

console.log(JSON.parse(xhttp.responseText));
baao
  • 71,625
  • 17
  • 143
  • 203