0

I am trying to figure out the below problem

var result = {"name":"Launches","Data":"50,56,34,25,25,55"} 

how can we print this variables value(result) into below variable using jquery or javascript

Series :[result];

any idea. I tried this by document.write() but it is writing into screen. But I need the above variables value as input for Series .

I need a result like this

Series:[{"name":"Launches","Data":"50,56,34,25,25,55"}];
5
  • 1
    what do you mean by 'values' and 'results'? Commented Apr 23, 2013 at 9:45
  • sorry guys, not explaining properly. I just to print a value like this, var result = {"name":"Launches","Data":"50,56,34,25,25,55"} Series :[result]; then the output should be like Series:[{"name":"Launches","Data":"50,56,34,25,25,55"}]; Commented Apr 23, 2013 at 9:50
  • In that case simply do document.write( "[" + JSON.stringify(result) + "]" ) Commented Apr 23, 2013 at 9:53
  • If you are looking to convert the data to an array you can do ... var series = result.Data.split(","); Commented Apr 23, 2013 at 9:55
  • are you trying to wrap your Object in an Array? Commented Apr 23, 2013 at 10:02

2 Answers 2

2

What do you mean by value?

result is an object which has 2 key-value pairs.

You can say result.Data to return "50,56,34,25,25,55",

or result.name to return "Launches"

Sign up to request clarification or add additional context in comments.

Comments

0

Use

document.write(result.Data);
document.write(result.name);

var Series = result.Data;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.