Need help with bidirectional AJAX requests

0 favourites
  • 6 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • The idea is very simple, I'm new to Contruct 2 engine and hence would really appreciate some help. The game that I'm making suppose to get a custom form via AJAX. I have written the PHP page that serves this form (for now it just echoes a simple text), and then created an AJAX request in the game. I have assigned a textbox to receive the PHP output, and it does so flawlessly. My question is this:

    • How can I make a custom HTML form retrieved from AJAX fill up the screen and not just a textbox? (I can make an HTML page that is 640x480, add custom CSS for the rounded-corner background and some text, input fields and a submit button)
    • If I'll be able to show my custom formatted HTML page, I can make it come with it's own AJAX handler (jQuery) that would handle a submit form action. So my second question is upon pressing this submit button, how do I get back to the game? Is there any way to bind an external call to continue or quit the game?

    P.S. This might also sound like a silly question, but I wasn't able to figure out how to quit the game upon certain events (when a player wins or looses for example). The only way I could think of was to destroy player. Is there an easier way?

    Thanks again, I really enjoy coming to these forums, so much talent! =)

  • It depends what "quitting the game" means to you. Closing the browser window?

  • No, quitting as in stopping the game from running (monsters from spawning, player/world from existence, etc). Any ideas?

    p.s. but this a separate topic on it's own, I would really like to get some help on the AJAX question.

    Thanks again.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • For the quitting problem

    -> Monster: Destroy

    -> System: set timescale to 0

    Should work

    For the other question... dunno, go see the plugin section in the forum, there's a list, maybe stuff like callJS or Jessejoh's HTML Elements pack could help.

  • Ashley may have some answer for _MD_'s question about AJAX in the first post.

  • If you're returning HTML to an AJAX request, Construct 2 can't do anything with that - you can't load HTML in Construct 2. You could try the iframe plugin and just show the URL in an iframe, or use CallJS to open it in a popup window.

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