JSON AJAX to Array

Get help using Construct 2

Post » Fri Aug 08, 2014 9:15 pm

Greetings, im trying to do some stuff with dynamic data from a AJAX php site this is my json result:

{
"c2array": true,
"size": "[1,2,10]",
"data": [
{
"nombre": "John Smith",
"puntos": 100
},
{
"nombre": "John Smith",
"puntos": 200
},
{
"nombre": "John Smith",
"puntos": 300
},
{
"nombre": "John Smith",
"puntos": 400
},
{
"nombre": "John Smith",
"puntos": 500
},
{
"nombre": "John Smith",
"puntos": 600
},
{
"nombre": "John Smith",
"puntos": 700
},
{
"nombre": "John Smith",
"puntos": 800
},
{
"nombre": "John Smith",
"puntos": 900
},
{
"nombre": "John Smith",
"puntos": 1000
}
]
}


Im trying to add this to an array using this:

On Ajax completed: Array - Load from JSON string AJAX.LastData

On debug i can't see anything loaded to my array

What im doing wrong ?
If anyone can upload a .capx example with an ajax to array i appreciate it.

Thanks
B
4
Posts: 4
Reputation: 283

Post » Sat Aug 09, 2014 12:26 am

System | On start of layout (or whenever you need it)- Request whatever.json (tag "whatever")

AJAX On "whatever" completed - Array | Load from JSON string ajax.LastData

Really all there is to it...


Still having trouble, upload a .capx and someone'll help, i'm sure!


EDIT: oh, one more thing, and I'm not positive it matters, but it might, aside from the very beginning and very end, my JSON files don't use any of these brackets: { }, only these: [ ]

I think it might have to do with the setup of your JSON file...

see if this makes sense, starting at the word "data"
"data": [[["x0"], ["x1"], ["x2"]],[["y0"],["y1"]],[["z0"],["z1"]]]}

at least, looking at some of mine, that's the format they're in.

hope that helps!
B
88
S
43
G
71
Posts: 601
Reputation: 43,669


Return to How do I....?

Who is online

Users browsing this forum: dop2000 and 34 guests