How do I set a dictionary based on external JSON using AJAX?

Get help using Construct 2

Post » Wed Dec 09, 2015 4:22 pm

Yo!

I'm currently working on a little test that loads a dictionary with some names using JSON data. The data works fine if I put the contents of the file in the field. However, when I try using AJAX to read the file from the project directory it doesn't work.

Image
Here's the code that should tell AJAX to read the file and then once finished, put it in the dictionary. I have the file imported within Construct 2. Also when debugging, the data shows up within AJAX as LastData.

Image
Here's the dictionary JSON file that I'm trying to use. Like I said, it works if I copy this into the "Load from JSON" field.

Am I missing something simple?

Thanks in advance!
Jack
B
4
Posts: 3
Reputation: 206

Post » Wed Dec 09, 2015 4:35 pm

Am I missing something simple?


Yes :)
if you use Ajax ,you don't need 2x"

Code: Select all
{"c2dictionary":true,"data":{"Key":"Value"}}
Image
B
64
S
23
G
7
Posts: 1,481
Reputation: 10,823

Post » Wed Dec 09, 2015 6:54 pm

Brilliant! Thank you very much!
B
4
Posts: 3
Reputation: 206


Return to How do I....?

Who is online

Users browsing this forum: jkmalau, MoscowModder, terence951, vegapomme27 and 9 guests