Ajax get last data via tag

Get help using Construct 2

Post » Sun May 03, 2015 7:35 pm

so I have several files to request (not sure how to request one line from a file).
How do I use the Ajax.LastData and get a specific tag? I'm horrible at explaining so if you understand this you're a god.
Website Twitter Indie Developer
B
20
S
6
G
4
Posts: 206
Reputation: 2,954

Post » Tue May 05, 2015 10:32 am

Ajax.LastData contains everything the requested page would show.

You either need to filter from the results, or make sure the relayed results just hold the info you need.
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,562

Post » Tue May 05, 2015 9:49 pm

How would I filter it? It seems like AJAX is very straight forward and doesn't have alot of options :/
Website Twitter Indie Developer
B
20
S
6
G
4
Posts: 206
Reputation: 2,954

Post » Wed May 06, 2015 2:12 pm

Could you explain more specific what you mean with "tag" ?
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,562

Post » Wed May 06, 2015 2:37 pm

Although this answer is so simple, it almost can't be the answer you are looking for:

in the request action you can set a "tag"

in the on completed action you can set that same "tag"..

so in the ajax on completed with that specific "tag" - you can set the actions for what to do with the data associated with that specific ajax request..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed May 06, 2015 7:23 pm

LittleStain wrote:Although this answer is so simple, it almost can't be the answer you are looking for:

in the request action you can set a "tag"

in the on completed action you can set that same "tag"..

so in the ajax on completed with that specific "tag" - you can set the actions for what to do with the data associated with that specific ajax request..

Yeah but it gets more complicated in my case :P
I want a text to change to the file requested with AJAX, so if I request several files (with texts in it) it will get confused with what I mean with "GetLast" :/
Website Twitter Indie Developer
B
20
S
6
G
4
Posts: 206
Reputation: 2,954

Post » Wed May 06, 2015 7:23 pm

lennaert wrote:Could you explain more specific what you mean with "tag" ?

When using the AJAX expression, for example AJAX.GetLast("tagFromRequest") now I know that one doesn't work but if there's any ideas of doing something similiar?
Website Twitter Indie Developer
B
20
S
6
G
4
Posts: 206
Reputation: 2,954

Post » Wed May 06, 2015 8:05 pm

condolent wrote:
LittleStain wrote:Although this answer is so simple, it almost can't be the answer you are looking for:

in the request action you can set a "tag"

in the on completed action you can set that same "tag"..

so in the ajax on completed with that specific "tag" - you can set the actions for what to do with the data associated with that specific ajax request..

Yeah but it gets more complicated in my case :P
I want a text to change to the file requested with AJAX, so if I request several files (with texts in it) it will get confused with what I mean with "GetLast" :/


What's more complicated?

Ajax on completed "tag" - set text to ajax.lastdata

Ajax on completed "othertag" - set other text to ajax.lastdata

from the manual:

LastData
The contents of the last response. This is set in the On completed trigger. If used in a different event, it contains the response of the last completed request.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed May 06, 2015 8:38 pm

condolent wrote:...
How do I use the Ajax.LastData and get a specific tag?....



Looking closer at this bit ...


When you perform an Ajax request, and the request is successful, the reply from that request will be available once, and can be caught using the on request complete trigger, referencing the tag you defined in your ajax request.

After the trigger on request complete has run, the Ajax.LastData will not be available anymore from that request, unless you perform the ajax request again with the same tag.
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,562

Post » Wed May 06, 2015 8:52 pm

If you want all your data loaded before working with it, you should store each LastData inside a dictionnary, using tags as keys.
B
67
S
28
G
24
Posts: 970
Reputation: 18,675

Next

Return to How do I....?

Who is online

Users browsing this forum: alextro, LachlanPontas, Ryan Kocourek and 6 guests