quote:
Originally posted by Leroux
I'm having trouble with the eval function however. I kept getting "Error: Expected ';' (code: -2146827284)". Now that I've changed it to your however, with the extra "(" and ")" in it, I instaed get "Error: Expected ')' (code: -2146827282)".
- Out of interest, why are the extra brackets added? Just so I fully understand the code I use.
That's because the "syntax" of your json object is incorrect so the parser throws an error
code:
SONIC THE HEDGEHOG:{"Title":"Sonic The Hedgehog","PSM":"A blue streak speeds by - It\\'s Sonic The Hedgehog"}
Sonic The Hedgehog:{"Title":"Sonic The Hedgehog","PSM":"Faster than the naked eye - It\\'s Sonic The Hedgehog"}
I got a better way to organize this output and deal it with JScript.
code:
{"results": [
{"Title": "Sonic The Hedgehog", "PSM": "A blue streak speeds by - It\\'s Sonic The Hedgehog"},
{"Title": "Sonic The Hedgehog", "PSM": "Faster than the naked eye - It\\'s Sonic The Hedgehog"},
{"Title": "Sonic The Hedgehog", "PSM": "test"}
]
}
JScript code:
xmlhttp.onreadystatechange = function(){
if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
var json = eval( '(' + xmlhttp.responseText + ')' );
for (var x = 0; x < json.results.length; x++){
Debug.Trace(json.results[x].Title + "\n" + json.results[x].PSM);
}
}
}