Why do I need ajax to load a json into an array?

Get help using Construct 2

Post » Thu Apr 02, 2015 9:38 am

Why do I have to use ~ ajax request 001.json and then ~ load from ajax.LastData

Instead of just ~ load from 001.json

I have tried to have the array just load from json but it seams to remain empty where as using ajax fills my array correctly.
B
6
S
1
G
1
Posts: 31
Reputation: 945

Post » Thu Apr 02, 2015 9:56 am

Ajax isn't going to work for me since you have to import the json file and pick it from a list.
B
6
S
1
G
1
Posts: 31
Reputation: 945

Post » Thu Apr 02, 2015 12:44 pm

Well I found that if I use the ajax request url instead of load file that I can get done what I wanted. But I still dont understand why ajax is required to load an array from a file but oh well.
B
6
S
1
G
1
Posts: 31
Reputation: 945

Post » Thu Apr 02, 2015 5:16 pm

You can use Array.Download to load JSON directly from a project file.
https://www.ravenheart.ca/home
Company name changed to avoid Facebook-type shenanigans

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,347
Reputation: 4,688

Post » Fri Apr 03, 2015 10:39 am

Doesn't Array.Download create a json with the arrays current values. or are you talking about something else?
B
6
S
1
G
1
Posts: 31
Reputation: 945

Post » Fri Apr 03, 2015 10:53 am

In the case of using an AJAX call to download a JSON file, the JSON file may be part of your project files or be stored online on a distant URL.

In both cases, AJAX is used to download and retrieve those external data and feed them into the array of your project.


The download action of the Array plugin does indeed "transform" the current values and state of the array into a JSON object.
You cannot "download a JSON into the array" using this action.
See the manual article on Arrays for more explanations about those actions.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
270
S
98
G
70
Posts: 7,267
Reputation: 75,644

Post » Fri Apr 03, 2015 12:11 pm

Yeah I figured it our using load from url and then just typing the filename of the imported file. But I still wish I could just use a load action from the array like array.load json and just skip the ajax thing completely. But oh well.
B
6
S
1
G
1
Posts: 31
Reputation: 945


Return to How do I....?

Who is online

Users browsing this forum: corporatedrone, gamarros, imhotep22, Nimothar, yuji567 and 15 guests