After making an ajax call, I received a result from an array that looks like result = [one, two, three];
However, I encountered an issue where I need to convert this into a valid array in order to iterate it properly. The problem arises because my string does not have quotes around the values.
Below is the code snippet I am currently working with. If you can provide guidance on the correct way to handle this situation, I would greatly appreciate it. Thank you.
xmlhttp.open("POST","SearchServlet", true);
xmlhttp.onreadystatechange =
function(){
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
resultData = xmlhttp.responseText;
// resultData = [one, two, three];
// need to make valid array to iterate it
for (var i = 0; i < resultData.length; i++) {
console.log(resultData[i]);
}
}
};