How does Ajax order last data?

  • I have found nothing on this and should be fairly simple.

    Say we have 2 ajax requests that trigger at the same time, does construct ajax.lastdata have an identifier tag for the lastdata or is that something that should be added/compared via the php/sql side?

    Meaning, does construct care if the data matches the request (I assume not).

    Unless someone knows, I will start planning to put identifiers into all my ajax requests.

    Thanks in advance!

  • AJAX requests can be tagged to identify the request. Then in the OnCompleted with that particular tag, the LastData will be for that specific request only.

    So basically the tag you are looking for is by event, in the AJAX On Completed condition.

  • Right, but if I call ajax 1, and ajax 2...and the data returned is ordered 2,1...and returns at the exact time.

    I'm already figuring this out a little better, and I'm 99.9% sure the answer is...

    When construct executes based on tag xyz, it does not care whether the lastdata matches the tag xyz....it just goes by what's in the lastdata.

    No biggy, but I'll have to add a column in phpadmin and use it as an criteria for

    example:

    on "xyz" completed &tokenat(AJAX.LastData,0,"|") = "xyz" then do whatever

  • I'm a little confused about what exactly your question is...

    Construct doesn't care what order the data is returned in.

    As long as the triggering event On Completed with a tag is run, within that event, AJAX.lastdata will give you the data from that specific tag's request. It doesn't matter if it comes back before, after, or at the same time as another AJAX request.

    Basically, you should never use AJAX.lastdata outside of an AJAX On Completed event. If you need to get it later, save it to an array or variable of your choosing.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • As long as the triggering event On Completed with a tag is run, within that event, AJAX.lastdata will give you the data from that specific tag's request. It doesn't matter if it comes back before, after, or at the same time as another AJAX request.

    This addresses my question...and I'm not sure that's 100% correct and trying to verify.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)