0

I want to create dynamic array from server data,

For example,

I need format in the following way:

["project1","project2","project3"]

This is my code

var arrayVal = [];
    for(var i=0;i<project.name;i++){
      //array generation
    }

project1,project2,.... are getting from server.

1 Answer 1

1

What you're looking for is JSON.parse. Here's an example copied form the JS terminal.

> a = JSON.parse('["project1","project2","project3"]')
["project1", "project2", "project3"]
> a[0]
"project1"

Now, be weary, JSON isn't integrated to all browsers yet. You can download a JSON script to emulate the native functions. See here and here

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

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.