[suggestion] Ajax plugin without singleglobal property

For developers using the Construct 2 Javascript SDK

Post » Fri Apr 08, 2016 1:59 am

@Ashely

Sometimes, user might want to pass values to the completed callback of ajax. User could save these values into another data structure which indexed by tag name of ajax task.
But how to index different ajax task if they has the same tag name?

A possible simple solution is, let each ajax task be an individual instance, save values in its private variables. Then user could get response passed values directly under completed condition.
To reach this goal, just remove "singleglobal" flag in edittime.js, imo.
B
108
S
26
G
271
Posts: 4,471
Reputation: 151,777

Post » Sat Apr 09, 2016 5:11 am

Or add a condition: on any tag completed, and read completed tag back by expression , this might solve the problem, problity.
B
108
S
26
G
271
Posts: 4,471
Reputation: 151,777

Post » Mon Apr 11, 2016 2:52 am

We would be very grateful if you could change this.
B
72
S
25
G
5
Posts: 90
Reputation: 7,277

Post » Mon Apr 11, 2016 3:29 am

Yes please, feels like it's very hard to differentiate AJAX instances sometimes
B
22
S
6
G
8
Posts: 328
Reputation: 6,651

Post » Mon Apr 11, 2016 10:38 am

rexrainbow wrote:But how to index different ajax task if they has the same tag name?

Why not give each request a different tag name? That's what tags are for.
Scirra Founder
B
397
S
236
G
88
Posts: 24,408
Reputation: 194,506

Post » Mon Apr 11, 2016 1:03 pm

@Ashley

For example, user press "S" will fire a ajax request, print a serial number of sending while completed.

User sends request with tag to "tag-" & sn , and add this condition-
Code: Select all
+ condition: on  "tag-" & sn completed
- print "tag-" & sn

"sn" is a variable set before completed.

This solution can not handle the case while waiting more then 1 request completing. It only gets one completing event.
Last edited by rexrainbow on Tue Apr 12, 2016 1:07 am, edited 1 time in total.
B
108
S
26
G
271
Posts: 4,471
Reputation: 151,777

Post » Mon Apr 11, 2016 2:03 pm

Yes I think the current "static" tag system is hard to work with for "dynamic" requests, like launched all at once through a loop, hence with the same tag
And while the Request URL action can currently allow to write a tag+variable name, the On Completed can't really make sense of it?
B
22
S
6
G
8
Posts: 328
Reputation: 6,651

Post » Mon Apr 11, 2016 5:35 pm

I think adding "on any completed" is the easiest and most consistent way to solve this. We're due a stable release soon but I'll look at it in the next beta cycle.
Scirra Founder
B
397
S
236
G
88
Posts: 24,408
Reputation: 194,506

Post » Tue Apr 12, 2016 1:01 am

@Ashley

Official timer behavior has similar problem, too. Add "condition:on any timer" could solve it.
B
108
S
26
G
271
Posts: 4,471
Reputation: 151,777


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 1 guest