How do I Clear Ajax.LastData

Get help using Construct 2

Post » Tue Oct 27, 2015 10:30 pm

Hi,

I know the question was already posted here, but the topic was "Solved". Actually it was just closed. I will try to explain what I need to do.

I have variable and text object which shows the lowest score to beat if you want to get to high scores table (global, from server). When the game starts everything is fine. Request is completed, variable gets the proper score, text object shows what it should.

So it looks kinda like this:

SYSTEM -- On start of layout:
Ajax: Request URL: blablabal "getscores";

AJAX -- On "getscores" completed:
System: Set Variable to tokenat(blablabnla)
TextObj: Set Text to tokenat(blablabnla)


And then, when player dies, I compare his score with lowest score mentionend above. If it's bigger - then he can upload his score. Up to this moment everything works great :)

The problem starts when the layout restarts on my mobile device (Windows Phone 8.1). Score remains the same as it was at the begining (both text and variable). And I see it's trying to request the url as at the begging TextObj shows string "Offline" in case the server is down or player has no internet connecttion. I need to restart app to make it refresh Ajax.LastData

Any suggestions?

Sorry for bad english ;)
Cheers,
B
6
Posts: 18
Reputation: 289

Post » Wed Oct 28, 2015 10:35 pm

Wooohooo! I've found the way around :) So frikin simple. Duh.

I just changed url in the action Ajax: Request URL

from: "http://www.blablabla.com/getscores.php"

to: "http://www.blablabla.com/getscores.php"&"?"&random(10000)

Thanks to this additional code, url changes every time Ajax tries to get url (it gets random number from 1 to 10000, so it's pretty unlikely that someone will hit the same number in a row). Because of this, our phone thinks it loads different data every time and doesn't use cache. The trick is that this additional code doesn't affect anything and everybody is happy :D

I know i didn't have to put "?" between ampersands, I could put it just after .php and then put one ampersand, but I just did it to remember what I did :P

Again sorry for my english ;)
Cheers!
B
6
Posts: 18
Reputation: 289


Return to How do I....?

Who is online

Users browsing this forum: boybacteria, Microbex, richcoz81, totoe and 24 guests