Make dynamic # of AJAX requests (and track)

0 favourites
  • 8 posts
From the Asset Store
Simple and easily editable template for a dynamic camera that zooms in and out based on how far apart the players are.
  • Am doing a level select, where level data is loaded from a MySQL database via AJAX/ conditional GET ( variable of level ID is sent via AJAX, Level Data returned )

    As below - the loop starts with the min/max numbers returned from the database, then requests the level data for each, however checking a dynamic AJAX request "MyLevel" & Variable is not working , any suggestions?

  • Is Ajax, like the browser full-screen call, only possible on a user-input event?

    I managed to get the multiple calls by simply iterating a variable instead of using the loop, an only moving to the next call once the first Ajax function was called.

    When it comes to switching to another layout to load the selected map, it doesn't load until user-input is initiated.

  • AJAX On Completed is a triggered event.

    My guess is that when AJAX request with tag "MYLEVEL7" (for example) is completed and at this moment your variable LVL_LOOP is not equal 7, then this event is skipped.

    How many levels do you have? You can simply make something this:

    AJAX On "MYLEVEL1" Completed -> Function call LoadLevelData(AJAX.LastData, 1)

    AJAX On "MYLEVEL2" Completed -> Function call LoadLevelData(AJAX.LastData, 2)

    AJAX On "MYLEVEL3" Completed -> Function call LoadLevelData(AJAX.LastData, 3)

    etc.

  • Thanks for the reply dude. Yeah, I got around it in the end by stepping a variable instead ( no loops ) so it'd load each level thumbnail one at a time.

    I'm still having odd issues trying to get the Ajax to work consistently though - is it like browser fullscreen requestes, where it must be linked to user input?

    I had things initially on a touch/mouse/keyboard event, but on changing them to "On Start of Layout" event, they don't fire.

    I'm wondering if there's a different/better way to pull down the data from MySQL to load/save levels and high score info?

    P.S - you game looks great - very creative take on the classic tetris!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Could you share your events sheet? AJAX doesn't require user input and should work on start of layout.

  • I tried it both ways, it only seemed to trigger on the touch action :

    It makes to ajax requests to return the min/max range of the saved levels by ID, to then run a loop from min to max, returning the level tile data from that.

    It works fine on button push, but then fails miserably on trying to activate the event from a "on start of layout" trigger.

  • Oh, and here's what it'd look like - Ideally I'd set limits and such on size of levels, at the moment it was just a prototype save/loader of tilemaps, the actual game isn't even made yet.

  • JohnnySix , Maybe this has something to do with previewing and cross-domain situation. Have you tried different browsers? Are there any errors in browser's Console Log?

    Also, I wonder what's going on in the blurred lines on your screenshot?

    Maybe you are assembling a URL string using some variable that hasn't been initialized yet on start of the layout?

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