I recently implemented ajax into my code, and it is working perfectly. It provides me with either JSON or an array as the output. Here is the snippet of code I used:
xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET","http://map_ajax_control.php",false);
xmlhttp.send();
var test = xmlhttp.responseText;
alert(test);
The variable 'test' contains the JSON or array data.
Now, I am looking to store this received data in a JavaScript array. However, I am facing some challenges when trying to decode the JSON data into a JavaScript array using the following code:
var output = new Array();
output = json_decode(xmlhttp.responseText);
Unfortunately, this code does not seem to be producing any output.
Can you please advise on how to achieve these two tasks successfully?