How do I get AJAX to work with HTML builds of my game?

0 favourites
  • 10 posts
From the Asset Store
20 high quality click sounds, ready to improve your game's UI instantly
  • AJAX works 100% perfectly until I export it to HTML, then it just doesn't pull the .json files it's supposed to, even though the files are in the build. It doesn't work on Itch.io, or the Construct Arcade, and it doesn't matter if I use the Scirra Arcade export option or not either.

    Has anyone had any issues with this, or maybe some insight that could help me figure out why it isn't working. I checked to make sure that both sites had HTTPS as well, which they do.

    Tagged:

  • check that all the files from the export are getting uploaded to the server. check the console (f12) to see if there are any errors - probably 404 (file not found)

  • Please post a screenshot of your code. It takes more time to request files from web, so if you are not using AJAX correctly, this may explain why it doesn't work.

  • check that all the files from the export are getting uploaded to the server. check the console (f12) to see if there are any errors - probably 404 (file not found)

    I'll check that now.

  • Please post a screenshot of your code. It takes more time to request files from web, so if you are not using AJAX correctly, this may explain why it doesn't work.

    I think this might be it, I didn't even think of that. Thank you.

  • check that all the files from the export are getting uploaded to the server. check the console (f12) to see if there are any errors - probably 404 (file not found)

    This is what it says in the console. I don't know what the issue would be here, but I'll look into it.

  • check that all the files from the export are getting uploaded to the server. check the console (f12) to see if there are any errors - probably 404 (file not found)

    I also rewrote some of the code to make the request again if it failed, and it just kept failing.

  • The HTTP 403 is an HTTP status code meaning access to the requested resource is forbidden. The server understood the request, but will not fulfill it.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The HTTP 403 is an HTTP status code meaning access to the requested resource is forbidden. The server understood the request, but will not fulfill it.

    I looked it up after that last quote. I don't know how to get around that. I'm just trying to make a simple io game that pulls a giant list of names to use for bots. Does anyone know another way I can easily write up a list of bot names in an array without manually setting it with events?

  • After further investigating, it seems that the requests are simply blocking .json and certain other file extentions from being requested. .txt files work perfectly fine with AJAX. I guess if I hosted my own website it might work with .json files, but it may actually be a security feature in browsers to protect users, rather than the website itself, but I'm not sure about that.

    Basically, don't use AJAX to request .json if you plan on hosting your game as HTML on a site you don't run. Use .txt instead, if you can.

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