Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parsing JSON with pure JavaScript [duplicate]

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);
like image 420
Evgenij Reznik Avatar asked Nov 01 '15 20:11

Evgenij Reznik


1 Answers

You can use JSON.parse():

console.log(JSON.parse(xhttp.responseText));
like image 183
baao Avatar answered Nov 06 '22 11:11

baao