ecb247247's Recent Forum Activity

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

    Thanks.

    Regards,

    Edgar

  • When previewing the game, or running an exported game in browser, press F12 and select Console tab. This is the first place you need to look when there are issues with AJAX.

    Thanks, got it now.

    So I am getting this error message:

    Access to XMLHttpRequest at 'https://gem24.cc/get_host_message.php' from origin 'https://preview.construct.net' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

    I have this code on top of all my PHP scripts and it has always worked.

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

    Do you know if i need to add something else in the script? Do I perhaps need to request data over HTTP instead of HTTPS?

    Thanks.

  • Have you find the error message in the console log?

    I have not seen any errors in the console log. Where exactly can i see it?

    Thanks.

  • Would anyone else have any other ideas?

    Thanks.

  • Sending AJAX requests on every tick is not a good idea, your server will probably not be able to respond that fast.

    Have you tried checking browser console log? When there are any issues with AJAX, you can usually find an error message in console log.

    Thanks for the response dop2000.

    I didn't find any error message in the console.

    Would you recommend another way other than placing it every tick? I was also thinking that since I have about 6 - 7 requests running simultaneously the reason they stop is because the server cannot respond to so many requests at one time. But for example when the player makes a move the opponent needs to have a request that checks for the message from the player as often as possible or else the game will be delayed if I have a request on lets say every 5 seconds to give the server time to respond. I also thought it could be poor connection on my side, but the network is fine and still some of the requests are able to get through.

    I would appreciate any ideas you might have. Perhaps a POST command would work more sufficient? Eventually I have to change all the requests to POST because I have to post the username of the players to make sure they are receiving data only for their hosted game, to not interfere or accidentally update other games.

    Thanks.

  • Hi.

    I am working on a multiplayer game where both player and opponent is using a request AJAX command to get data from the database, can for example be that it gets info if both players are ready to start a new game and so on... So what happens is after a few games some of the requests (never all of them at the same time) seems to stop and the game stops because its waiting to receive the data before continuing. Sometimes after waiting a while 30 sec - 1 min the request resumes and the game continues, while other times it is stuck forever.

    I am using the request command on every X amount of sec and tried to have it on its own and inside a every tick command, and both are producing the same results.

    Sometimes I am able to play a game for a couple of min without anything happening, but sooner or later it always happens..

    I know it is the request command as I have used "On Error" and whenever there is an error with the request I have added a custom text that shows up always when the game stops.

    I wonder if anyone of you are familiar with AJAX request and have had this issue before, and maybe knows some suggestions I could try to fix it.

    Thanks a lot.

    Regards,

    Edgar

  • Hi,

    When i resize the browser window or go into full screen, the font size of the text inside the buttons gets smaller, like shrinking. Does anyone know how to fix this?

    Regards,

    Edgar

  • Hi all,

    I was not sure where to put this, so feel free to put it where this belongs.

    Is anybody else experiencing any issues at the moment when loading projects or previewing?

    I'm having issues running 2 preview windows at the same time? It was working fine for me having two projects open and previewing the same project until this afternoon, now when i run the second preview i get a couple of error messages.

    1. Popup box saying error loading layout.

    2. Error message telling me that the project can't run in Chrome

    3. A blank screen with the Construct 3 logo

    I've tried clearing cache and cookies but i still get the same issue.

    It's important to having this working as i'm working on a multiplayer project.

    Regards,

    Edgar

  • Yes that might be, the server are in Denmark. Anyway it seems to be loading between 30 - 40 seconds now without https, tested on multiple laptops and other testers have confirmed too coming from different countries.

    Thanks for your help, appreciate it.

    Enjoy the rest of your weekend.

    Regards,

    Edgar

  • Thanks for testing.

    That can't can't be right, are you sure? For me it takes 1 minute in Edge, even same time in Chrome but the loading is not consistent. The game is 85mb, it was actually 156mb and then it loaded in about 30 seconds, now after i removed old objects and reduced the size it takes longer to load, where is the sense in that?

    Could you give it a try now with the HTTPS off, for me it loads in 30 - 40 seconds using Chrome.

    gem24.cc/medievalslots

  • Thanks for your help guys,

    Clearly it's a browser issue, if you try loading the game in Edge it's loading correctly and is consistent, but in Chrome and Firefox it might be stuck on 4% for a while, then jump to 55%, then 100%, and also takes much longer time to load.

    Although worth mentioning as i thought, when turning of HTTPS the game loads normally again in Chrome only.

    Could anyone test please and confirm loading the game in Edge and Chrome browser and let me know if you can reproduce what i got?

    gem24.cc/pirateslots

    Thanks again for your help.

    Regards,

    Edgar

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hey thanks for the reply and sorry for the late response, but better late than sorry right.

    I didn't have to do anything of that btw, i just had to assign float to the balance when i assign the variable and it updated the currency automatically.

    Regards,

    Edgar

ecb247247's avatar

ecb247247

Member since 6 Sep, 2019

None one is following ecb247247 yet!

Trophy Case

  • 5-Year Club
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

8/44
How to earn trophies