AJAX Example with Construct 2

6

Index

Stats

23,919 visits, 72,447 views

Tools

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 14 Sep, 2011. Last updated 19 Feb, 2019

Capture the Returned Data

We now need a way to capture the returned data. This is where the AJAX.LastData property comes in.

In the Event sheet, we will add another event that will check to see if the AJAX event has completed.

Click Add event.

The Add event window appear. Select the AJAX object and click the Next button.

Double click the On completed condition.

For this tutorial, leave it as-is and click the Done button.

Our second event now appear in the Event sheet.

Click the Add action link.

Click on the txtReturnedData text object and click the Next button.

The action we want to use is the Set text action. Choose it then click the Next button.

In the Text input box, enter:

AJAX.LastData

Our set up is done. Export the Construct 2 files and upload the files to the server. Make sure that you actually use a real target file that will return data.

You should be able to go to your page location, click the image and it will load the data. The earlier example we used is located at:

http://www.jtadeo.com/scirra/ajax/ajaxexample1/

  • 0 Comments

Want to leave a comment? Login or Register an account!