I am doing ajax, I have the following problem and javascipt fails with an eval expression. I am using IE9 browser. It gives error SCRIPT1007: Expected ']' when expressing eval. The following is a javascript function, and you can also find the problem that I have indicated with arrows.
<script type="text/javascript">
function callAjax(){
var xhr = new XMLHttpRequest();
xhr.open("GET","ajax");
xhr.send(null);
xhr.onreadystatechange = function(){
if(xhr.readyState == 4 ){
if(xhr.status==200)
var arrStr = xhr.responseText;
***var arr = eval(arrStr);------------->problem area***
var list ="";
for (var i=arr; i<arr.length; i++){
list+=arr[i]+"<br>";
}
document.getElementById("msg").innerHTML=list;
} else if ( xhr.status==404) {
document.getElementById("msg").innerHTML="<h6 style='color: red'>Invalid Path</h6>"
}
}
}
</script>
source
share