Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.