Ajax and List items

Get help using Construct 2

Post » Thu Feb 20, 2014 8:07 pm

Hi :)

I just try Ajax feature and would like to make more than just requesting, i would like to use datas returned by server.
So, to understand, i made a php script returning a simple C2 array
Echo of the PHP script
Code: Select all
{"c2array":true,"size":[4],"data":["Level1","Level2","Level3","Level4"]}


I try to put that in a C2 Array and it work well
Now i would like to populate a https://www.scirra.com/manual/155/list

How could i iterate on each data to use List method named Add item
Is there a better way to load that ?
B
8
S
2
Posts: 35
Reputation: 838

Post » Thu Feb 20, 2014 8:40 pm

Your best bet is by tokenizing your data into a single string, then loop for each token to add elements to the list.
B
67
S
28
G
24
Posts: 970
Reputation: 18,675

Post » Thu Feb 20, 2014 9:44 pm

I find the method to tokenize data so it ll be easy!
I'm not sure that is a good idea to send JSON, Plain will be enough...
What do you think about that?
B
8
S
2
Posts: 35
Reputation: 838

Post » Fri Feb 21, 2014 12:07 am

Plain is good enough, no need to encapsulate anything in an object. As you said, tokenizing make it so easy ! ;)
B
67
S
28
G
24
Posts: 970
Reputation: 18,675


Return to How do I....?

Who is online

Users browsing this forum: Darth Crusher and 2 guests