0 Favourites

JSON AJAX to Array

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

    [quote:stm96qa5]

    {

    "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:

    [quote:stm96qa5]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

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • 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!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
187 45,139
Yann's avatar
Yann
Unread hot topic
0 Favourites
[PLUGIN] JSON++
38 5,602
Syazanie Amirin's avatar
Syazanie Amirin
Unread hot topic
0 Favourites
Fill Array with Sprites
48 2,316
Congrats2u's avatar
Congrats2u