Jump to content

JSON issue


monkeytooth

Recommended Posts

Im trying to do this via native javascript without library help if I can...

 

here is the JSON (its valid):

{"figures":[["10","Other"],["45","Operations"],["78","Engineering"],["39","Admin"],["48","PG&WS"],["40","Government"],["2","Power"],["81","Thrust"],["10","Foreign"]],"totalRows":9}

 

all I want to do is alert the "totalRows" specificly. Example:

var displayJSON = $('textarea#chartJSON').val();
alert('totalRows: '+displayJSON.totalRows);

 

However the result is coming up as invalid "undefined" more specifically. The variable itself "displayJSON" will display the above JSON string. Right now I have the string rendering in a textarea when the page loads via PHP. So I am wondering if I am approaching it the right way. Or if for some reason storing it in the textarea first then getting that textarea's value is just giving the wrong string type and it cant read as json. Maybe I am just wrong about native support with JSON in JavaScript. Should I just use jquery (since I already am) and go with the parseJSON() function?

Link to comment
https://forums.phpfreaks.com/topic/236407-json-issue/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.