This is probably something simple but i can't figure out the solution. I have a Javascript that ask for some data from a PHP. Data included in an array. I am actually receiving the array from php but i can't fragmented it.
this is the PHP file:
<?php
$q1 = intval($_REQUEST["qq1"]);
// some data
// $reply_1 = "daTa1";
// $reply_2 = "data2";
// $reply_3 = "987654321";
//..............
$arr = array(
$reply_1,
$reply_2,
$reply_3,
$reply_4);
echo json_encode($arr);
?>
and the below is part of the javascript
var datareceived= new Array (15);
var url = "theabovePHP.php?qq1="+i;
function reqListener () {
console.log(this.responseText);
}
var oReq = new XMLHttpRequest();
oReq.onload = function() {
datareceived= this.responseText;
}
oReq.open("get", url, false); // false wait
oReq.send();
document.getElementById('div_display_part_OF_data').innerHTML = datareceived[1]+" some data " + datareceived[2];
The issue is that i am receiving the data in var datareceived, that looks like this ["daTa1","data2","987654321","2015/09/27 16:20:48","35.1320112","33.344586"] but I can't have them as an array. When I ask the datareceived[3], this should be 987654321, i receive "T" (the 3rd charachter in datareceived) etc..