How do I make a condition with Ajax.lastData

Get help using Construct 2

Post » Fri Jun 09, 2017 9:18 am

Hi, I have an ajax request and the on complete event, with the value returned by te request (Ajax.lastData) I want a condition, if its lower than 3 do one thing, greater another thing. Thank you!

Image
B
3
Posts: 3
Reputation: 181

Post » Fri Jun 09, 2017 9:24 am

Event 4, instead of gamesPlayed put Ajax.LastData there.

If you get a NaN error, encapsulate the Ajax.LastData with int() i.e. int(Ajax.LastData)
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,562

Post » Fri Jun 09, 2017 9:43 am

oh that wasnt the right image, I actually have set the variable gamesPlayed to int(score.LastData) but it doesnt work. And for the image test, the text input remains empty.


Thanks
B
3
Posts: 3
Reputation: 181

Post » Fri Jun 09, 2017 9:47 am

Did you rename the ajax object to "score" ??
if not, rename int(score.LastData) to int(Ajax.LastData)


EDIT: nvm

Just noticed you did.


Check your console for the ajax request response and see if you actually get a value from your request
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,562

Post » Mon Jun 12, 2017 6:02 pm

Yes, I can see the response on the console, but the Ajax on completed event its never fired.

Image
Image
B
3
Posts: 3
Reputation: 181

Post » Tue Jun 13, 2017 8:10 am

Did you try it without the extra conditions ?

Your response appears to be zero, but the second condition requires it to be higher or equal to 3.
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,562


Return to How do I....?

Who is online

Users browsing this forum: digitalsoapbox, RetrocadeMedia and 1 guest