javascript parsing question
hi,
I'm having some serious trouble trying to parse a JSON file in javascript. I have done this outside of max with no (well maybe some) issues..
Basically I'm making an XMLHttp request in the exact same way as documented in the "maxurl" helpfile.
this is my .js file so far.
var ajaxreq;
function readystatechange_parsejson()
{
if (this.readyState ==4 && this.status == 200){
post(this.responseText,"\n");
var myobj = JSON.parse(this.responseText);
post(myobj.list);
}
function fget(){
ajaxreq = new XMLHttpRequest();
ajaxreq.open("GET","https://api.myjson.com/bins/3ymxq");
ajaxreq.onreadystatechange = readystatechange_parsejson;
ajaxreq.send();
}
it keeps telling me that myobj.list is undefined therefore i can't use it in a for loop to iterate through the json..
when posting the myobj variable it just gives it a jsobject number and no information..
maybe i should just use JSON.stringify as that is actually giving me a string to play with..
help??
Don't worry..
fixed it
Shaun I am having the same problem !!I tried JSON.stringify and retrieved a string to play with. But for my use parsing to JSON is useful. I used JSON.parse and further feed into the dict object. But in the console it shows .. dict cannot understand the input.. !
help ??
Haha yeah if you fixed it, post the answer. other wise we're just wading through essentially dead links.