The problem I am facing is this that when I pass an array from a PHP file to another file javascript using Ajax I get correct input but the length of the array is wrong. I don’t know what I am doing wrong. These are my two files some code.
Firstfile.php:
function check()
{
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function()
{
if(xmlhttp.readyState==4 && xmlhttp.status==200)
{
graphData=xmlhttp.responseText;
alert(graphData);
// getting alert [["01_Mar_2016",38430],["02_Mar_2016",97183],["03_Mar_2016",107122]]
alert(graphData.length);
//getting alert 68 but it should be 3
}
else if(xmlhttp.status==404)
{
graphData="File not found";
}
}
xmlhttp.open("GET","SeocndFile.php",true);
xmlhttp.send();
}
SeocndFile.php
while($result = mysql_fetch_assoc($qryResult))
{
$data[] = array((string)$result['mimiDate'], (int)$result['sumMimi']);
}
print json_encode($data);
//print like this[["01_Mar_2016",38430],["02_Mar_2016",97183],["03_Mar_2016",107122]]
//which is correct.