AJAX Crossdomain please help

0 favourites
  • 5 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • 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

  • On the website you're trying to connect to, is my own humble guess.

  • 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>";

    ?>

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Have a look at the AJAX manual article that has a paragraph about cross domain in preview.

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