Run AJAX in preview mode

Discussion and feedback on Construct 2

Post » Mon Oct 03, 2011 12:50 am

Hi,

From AJAX Tutorials I know that ajax can not run successfully in preview(run layout) mode.
Maybe C2 Editor can add a resource folder in Projects window to import files like import sound/music. And put these files to the same folder with index.html in preview(run layout).rexrainbow2011-10-03 03:05:19
B
97
S
22
G
176
Posts: 4,108
Reputation: 103,019

Post » Mon Oct 03, 2011 8:33 am

same question for me. How to run Ajax in preview mode?
B
12
S
5
G
5
Posts: 80
Reputation: 3,572

Post » Mon Oct 03, 2011 3:24 pm

At present I don't think it can. The easiest way to preview your work is to download and install XAMPP onto your computer. Then just put all the application files and php files you need into the htdocs folder of the xampp directory. Then open your browser and go to http://localhost and select the folder your application is in. Viola! Should work like a charm and function way better than the C2 preview.

XAMPPdroptank212011-10-03 15:26:43
B
22
S
9
G
3
Posts: 202
Reputation: 3,645

Post » Mon Oct 03, 2011 3:35 pm

I guess, the preview is to create a temporarily folder, put index.html and all related javascript files into.
Because the target file of ajax's request is not in this folder, the request failed.
If put the target file into the same folder, the execution environment may be the same as exporting.rexrainbow2011-10-03 15:37:38
B
97
S
22
G
176
Posts: 4,108
Reputation: 103,019

Post » Mon Oct 03, 2011 4:09 pm

it is temp and it will not work.
B
12
S
5
G
5
Posts: 80
Reputation: 3,572

Post » Tue Oct 04, 2011 5:02 am

I use WAMP. It's free and it comes with a Windows installer. That's what used for that tutorial. For OSX, I use XAMPP mentioned earlier.
B
18
S
8
G
7
Posts: 120
Reputation: 5,625

Post » Sun Oct 09, 2011 2:33 am

You need to send the header:

Access-Control-Allow-Origin: *

in the response from the server you send the AJAX request to. Otherwise, the browser will block the request.
Scirra Founder
B
357
S
214
G
72
Posts: 22,945
Reputation: 178,206

Post » Sun Oct 09, 2011 3:48 pm

The steps are list below:

1. create a capx.
[code]+System: Start of layout
- Ajax request "readme.txt" (tag "read")
+ Ajax: on "read" complete
- Set text to AJAX.LastData[/code]

2. use run layout.
of course, the ajax will not be completed.

3. search "preview.html" from my c:\
for example, I got the "preview.html" in path
"C:/Users/Hau/AppData/Local/Temp/c2-12HER2/html5/preview.html"

4. open this folder. There are many js files like AJAX_plugin.js, Text_plugin... etc.

5. put "readme.txt" into this folder.

6. open "preview.html"(in this folder) on browser.
Now, the "readme.txt" file is in the same folder within "preview.html". And the Ajax is completed.

Since this folder is created by C2 editor, and editor copy all necessary js files into it.
Maybe editor can put "readme.txt" into this folder. So that "readme.txt" can be found in this case.rexrainbow2011-10-09 15:55:22
B
97
S
22
G
176
Posts: 4,108
Reputation: 103,019

Post » Sat Nov 12, 2011 12:12 am

Hi, I maybe stupid... but I've installed Xampp
When I connect to localhost, I have the Xampp page, where I can check the status etc...

What do I do from there to launch the game ?

I've copied the files from the export to a directory in htdocs.
But if I type the Url   localhost/xampp/htdocs/game/index.html

It doesn't work..
nothing is found.


Is there another way or am i doing something wrong ??

Thx
B
12
S
2
G
5
Posts: 73
Reputation: 3,570

Post » Sat Nov 12, 2011 11:03 pm

Its probably localhost/game/index.html
B
2
S
2
G
5
Posts: 448
Reputation: 2,546

Next

Return to Construct 2 General

Who is online

Users browsing this forum: Axiomaltd, gamecorpstudio, Yahoo [Bot], Zonacas and 9 guests