How do I combine function and AJAX?

0 favourites
  • 3 posts
  • So I have two functions that one of them is depended by the other function.

    Example:

    Function A calls AJAX get data wait-for-previous-actions browser log AJAX.LastData set return value from AJAX.LastData Function B (async) Has localValue X as number, default number -1 set X with value Functions.A wait-for-previous-actions browser log x

    Supposedly the AJAX get value 20. I expect the browser log on function B will returns 20 but returns -1 instead.

    the log ordering also didn't quite right, example in console log ordered chronologically:

    {variable x}

    {AJAX.LastData}

    Is there any workaround that I have to do?

    Tagged:

  • I'm sorry since I cannot edit my post I'll rewrite the example for better visual

    Function A

    calls AJAX get data

    wait-for-previous-actions

    browser log AJAX.LastData

    set return value from AJAX.LastData

    Function B (async)

    Has localValue X as number, default number -1

    set X with value Functions.A

    wait-for-previous-actions

    browser log x

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Try using Ajax->On Completed instead of wait for previous actions in the same condition..

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