I have XMLHttpRequest() function given below
var searchFriendRequests = function (userid) {
var xhr = new XMLHttpRequest();
xhr.open(\'G
When you make your ajax request you can provide dataType option:
dataType: 'json'
For such request when you receive response:
If
jsonis specified, the response is parsed usingjQuery.parseJSONbefore being passed, as an object, to the success handler. The parsed JSON object is made available through theresponseJSONproperty of thejqXHRobject.
you can access your data like:
var data = xhr.responseJSON
Full example:
$ajax.({
dataType: 'json',
success: function( xhr ) {
var yourData = xhr.responseJSON;
console.log( yourData );
},
});