removing quotation marks from responsetext property

ajax, javascript, json

Solution

Try this:

JSON.parse(xhr.responseText);

Explanation:

It's a JSON response, which means the server is responding with JSON format. In order to use it properly in JavaScript, you need to parse the string as JSON using the `JSON.parse()` function. That will convert the JSON object to the response you need.

Problem

I am trying to remove quotation marks from the `responseText` property of a `XMLHttpRequest` object. My output is : ``` "[{"data":[[0,28]],"label":"Atyc-1"},{"data":[[0,13]],"label":"Atyc-10"},{"data":[[0,16]],"label":"Atyc-11"},{"data":[[0,17]],"label":"Atyc-2"},{"data":[[0,5]],"label":"Atyc-3"}]" ``` what I need is: ``` [{"data":[[0,28]],"label":"Atyc-1"},{"data":[[0,13]],"label":"Atyc-10"},{"data":[[0,16]],"label":"Atyc-11"},{"data":[[0,17]],"label":"Atyc-2"},{"data":[[0,5]],"label":"Atyc-3"}] ```

Original source