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.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.