I am getting this from single PHP file with xmlhttprequest, Here is the result I am getting.
{request: {…}, service: Array(2)}
service: (2) [{…}, {…}]
request: {…}
[[Prototype]]: Object
In the service property, I am getting 2 elements in an array and in request 1 array.
I want to separate both array then split value of the both array, so can any one help me with this how to do it in JavaScript.
Here is the code I am using to get data from PHP :
var request = new XMLHttpRequest();
request.open("POST", API_PATH + 'data.php');
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
request.onreadystatechange = function () {
if (request.readyState === 4) {
request.onload = function(){
let datareq = JSON.parse(request.responseText);
console.log(datareq);
}
}
};
const data = {str , ltr};
request.send(JSON.stringify(data));