AJAX Crossdomain please help

Get help using Construct 2

Post » Tue Aug 13, 2013 3:38 pm

In the manual, it says this:

If you want AJAX requests to your server to work from any domain, or in preview, you can configure it to send the following HTTP header: Access-Control-Allow-Origin: *

Can somebody tell me where to put this line? I'm using the preview inside Construct 2 and I don't see any PHP file in the Construct 2 directory.

Please help!

Thank you
B
4
Posts: 7
Reputation: 464

Post » Tue Aug 13, 2013 7:36 pm

On the website you're trying to connect to, is my own humble guess.
B
9
S
2
G
2
Posts: 59
Reputation: 1,024

Post » Tue Aug 13, 2013 9:29 pm

On the website you're making the request to, make sure the following is the first thing printed:

header('Access-Control-Allow-Origin: *');

For Example (http://mywebsite.com/myfile.php):

<?php
header('Access-Control-Allow-Origin: *');
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
echo "<Catalog>\n\t";
echo "<data result=\"1\" reason=\"I like bacon\" />";
echo "\n</Catalog>";
?>
Epic Space Online - Google it!
B
34
S
10
G
5
Posts: 165
Reputation: 6,687

Post » Tue Aug 13, 2013 10:53 pm

Thank you for that part but when you're previewing (testing) from within Construct 2 you don't have a web site and I don't have any php file.

Edit: I finally found a Google Chrome extension called Allow-Control-Allow-Origin: * and it's working good.
B
4
Posts: 7
Reputation: 464

Post » Wed Aug 14, 2013 1:57 am

Have a look at the AJAX manual article that has a paragraph about cross domain in preview.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
284
S
109
G
91
Posts: 7,319
Reputation: 87,487


Return to How do I....?

Who is online

Users browsing this forum: Darth Crusher, Yahoo [Bot] and 11 guests