Help with Ajax, please...

Get help using Construct 2

Post » Sun Oct 16, 2016 3:55 am

Hi, I am working on this game and I need to use Ajax to make file requests. Right now I have 2 text files (.txt) that I have imported. But I can only make one of them work. Is it possible to have 2 Ajax Objects like AJAX1 and AJAX2? Because I can't seem to find a way to do that.

I have checked the code, the tags are different. I posted a link to a screenshot. This image shows the request that is not working. the one that works is identical except for the fact that I create the text and make the request via a SIGNAL.

Now this trim(tokenat(AJAX.LastData,random(20,21),";")) is identical in both requests except for the random numbers in the brackets. Could this be it? Sorry I am a noobie.

The one below (see pic), doesn't work. I tried everything and even ended up creating a button to click on it and see if it would work. I hope I was clear enough.

Appreciate any help. Thanks.

Image
B
19
S
4
G
2
Posts: 97
Reputation: 2,244

Post » Sun Oct 16, 2016 8:49 am

Loading with the action'Request project file' can take a while. It is mostly not ready in the next action. And it can take several tick. That is why you have the condition 'On completed'. The tag is there to know which request pairs with which completion.

So in general you ..

Some condition that makes the action done only once (like on startup of layout)
The action 'Request project file' ("tag")

A new top level condition 'On completed' ("tag")
The actions that assign the LastData

Be aware that, because the loading of files can take several ticks, the rest of your events are not valid. Because the needed data are still missing (not loaded yet).

I see most people in here use Groups and dissable/enable them. To exclude events from runnning as long as the data are not in place.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sun Oct 16, 2016 12:57 pm

99Instances2Go wrote:Loading with the action'Request project file' can take a while. It is mostly not ready in the next action. And it can take several tick. That is why you have the condition 'On completed'. The tag is there to know which request pairs with which completion.

So in general you ..

Some condition that makes the action done only once (like on startup of layout)
The action 'Request project file' ("tag")

A new top level condition 'On completed' ("tag")
The actions that assign the LastData

Be aware that, because the loading of files can take several ticks, the rest of your events are not valid. Because the needed data are still missing (not loaded yet).

I see most people in here use Groups and dissable/enable them. To exclude events from runnning as long as the data are not in place.



Thank you. It seems to me that there's something that I am doing thta's wrong.

See example of what I am trying: http://www.geocities.ws/kikoriogames/AJAX.capx

In the example there are 2 requests and different text boxes TEXT1 and TEXT2 are to SET TEXT, but only TEXT2 works.

I am sure there's something I am doing wrong.


Thanks. Have a happy Sunday!
B
19
S
4
G
2
Posts: 97
Reputation: 2,244

Post » Sun Oct 16, 2016 1:40 pm

B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072

Post » Sun Oct 16, 2016 1:57 pm

korbaach wrote:AJAX.capx


And I did read a lot about the Dictionary Action I just couldn't get it done! I am fairly new at this. Thanks to people like you I am getting around it.

Alrightttttttttttt!!!!!!!!!!!!!!! Thank you a lot!!! Neat!!!!!!!!!!!!! Have a great day!!!!!!
B
19
S
4
G
2
Posts: 97
Reputation: 2,244


Return to How do I....?

Who is online

Users browsing this forum: max2612 and 9 guests