Ajax Plugin - server side setup

0 favourites
  • 10 posts
From the Asset Store
A whole set you need to create a gorgeous winter 2d game
  • I have a txt file hosted on Dropbox that I access using the AJAX plugin to display text within my game and everything is working great, exactly as planned.

    However, I decided to move the text file to a different host, NearlyFreeSpeech, and it is now located at http://nsgames.nfshost.com/testalert.txt (as an example). It is now suddenly inaccessible from this url using AJAX plugin. The file can be loaded when pasted into a browser but isn't being read by the AJAX plugin.

    Is there any reason for this? If the file is available online and everything is setup exactly the same as before when it was hosted on Dropbox is there any reason this should fail? Is there some kind of setting, server side, that needs tweaking?

  • .capx is required because without .capx, we can't reproduce your problem

  • The problem isn't within c2 though. I have it all working great, exactly as I need when the text file is hosted on Dropbox. So my events aren't the issue.

    It's only when I change the url to point to the same text file but hosted on my own web hosting that it doesn't retrieve the file. Which is what has lead me to ask, is there a specific setting required at the host side? Do I need to enable access somewhere server side?

  • You need to press F12 to check console log that tells what's the problem

  • Thanks! Here's what I got...

    XMLHttpRequest cannot load http://nsgames.nfshost.com/testalert.txt. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:50000' is therefore not allowed access.

    How do I fix that?

  • Thanks! Here's what I got...

    XMLHttpRequest cannot load http://nsgames.nfshost.com/testalert.txt. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:50000' is therefore not allowed access.

    How do I fix that?

    http://www.bing.com/search?q=%27Access-Control-Allow-Origin%27+&qs=n&form=QBLH&pq=%27access-control-allow-origin%27+&sc=8-30&sp=-1&sk=&cvid=1ce44841a1c546968b282332a55704d1

  • Please don't patronise me. I am more than capable of using a search engine. I haven't found a solution I have been able to implement.

    If anyone else has anything worthwhile to contribute I'd really appreciate any help.

  • Please don't patronise me. I am more than capable of using a search engine. I haven't found a solution I have been able to implement.

    If anyone else has anything worthwhile to contribute I'd really appreciate any help.

    Did you bother reading any of the matches for the search engine? The issue is fully explained and is not a C2 issue. You should set this up on your server or contact your hosting provider to get the issue fixed.

  • Thanks, Captain Obvious. My topic title is "Ajax Plugin - server side setup", so I'm well aware it's not a C2 specific issue.

    I was merely posting incase anyone else had encountered this issue and had a simple solution. Your response of posting a link to search engine results doesn't help anything. It's an immature dig suggesting I was being lazy by enquiring here. I wasn't looking for a quick fix, I was looking for help from someone experiencing an AJAX related issue within a C2 environment.

    I am more than capable of pasting my error message into the search engine. I did indeed do that, but as I have no knowledge of web programming/scripting etc it all means nothing.

    If this forum was full of smart arses like yourself it'd make for a very difficult place to ask for help.

    And in the spirit of what this forum should be about, I have the solution for anyone else who may encounter this problem. For me, I had to add the following to a file named ".htaccess"

    Header add Access-Control-Allow-Origin "*"

    Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"

    Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Looking for reasons to be offended is no way to go through life.

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