AJAX and CORS Issues

0 favourites
  • 1 posts
  • Hi,

    Have anyone been successful in sending data with POST using AJAX to PHPH scripts and retrieving data back to Construct?

    I myself have not had any issues with sending a one time POST then another one at a later stage in the game, but as soon as I started sending POST requests every X amount of seconds since the game I'm working on needs to check for a message every 2 seconds, that's when the problem started with CORS.

    All I have used all a long is this code at the top of my PHP scripts:

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

    This is working, and I am able to play a few game rounds before the game stops and in the console log it's saying that the request has been blocked by CORS since NO Access-Control-Allow-Origin is present, but it is present.

    Then I wonder why don't I get this error in the beginning, and it only comes later in the game?

    I have been reading online on how to stop CORS from blocking the requests and have found bunch of code to add together with the above header, but none of them worked. Even to add some code to .htaccess.

    I seem to have been trying everything for literally months now, and it's really frustrating since this stops me from properly previewing and testing the game.

    If anyone know how to fix this issue I would be very grateful if you could share the fix with me her.




  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)