Need help with bidirectional AJAX requests

Get help using Construct 2

Post » Tue Jan 31, 2012 3:59 am

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! =)
B
3
Posts: 5
Reputation: 285

Post » Tue Jan 31, 2012 9:23 am

It depends what "quitting the game" means to you. Closing the browser window?
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Wed Feb 01, 2012 1:11 am

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.
B
3
Posts: 5
Reputation: 285

Post » Wed Feb 01, 2012 10:03 am

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.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Wed Feb 01, 2012 10:14 pm

@Ashley may have some answer for _MD_'s question about AJAX in the first post.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,805

Post » Fri Feb 03, 2012 1:47 am

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.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,630


Return to How do I....?

Who is online

Users browsing this forum: selaus and 0 guests