Skip navigation.
Arch2Arch Tab BEA.com

Article: An Introduction to JSON
Subject:  EVAL, XSTREAM or just NEW Function
Date:  2007-03-19 06:15:59
From:  dols

Hello,

I read the comment that XSTREAM is ok instead of EVAL.
I found the following which also works. Can anyone explain this code to me?

than"ks,

Frens

xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
if (xmlhttp.status==200) {

// HERE IT COMES
var local=new Function("return "+xmlhttp.responseText)();

// and 'local' can be accessed as with EVAL

window.alert("Code - Name\n"+local[0].id+' - '+local[0].lat);

} else {
alert(not found");
}