Ajax Plugin - server side setup

Discussion and feedback on Construct 2

Post » Tue Dec 30, 2014 2:37 am

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?
ImageImage
Mr. Green - Platform/puzzle game out now!
B
25
S
7
G
1
Posts: 222
Reputation: 3,350

Post » Tue Dec 30, 2014 3:18 am

.capx is required because without .capx, we can't reproduce your problem
B
99
S
35
G
29
Posts: 3,139
Reputation: 28,421

Post » Tue Dec 30, 2014 4:21 am

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?
ImageImage
Mr. Green - Platform/puzzle game out now!
B
25
S
7
G
1
Posts: 222
Reputation: 3,350

Post » Tue Dec 30, 2014 4:41 am

You need to press F12 to check console log that tells what's the problem
B
99
S
35
G
29
Posts: 3,139
Reputation: 28,421

Post » Tue Dec 30, 2014 3:40 pm

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?
ImageImage
Mr. Green - Platform/puzzle game out now!
B
25
S
7
G
1
Posts: 222
Reputation: 3,350

Post » Tue Dec 30, 2014 4:21 pm

FredQ wrote: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
B
21
S
5
Posts: 196
Reputation: 1,984

Post » Tue Dec 30, 2014 4:32 pm

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.
ImageImage
Mr. Green - Platform/puzzle game out now!
B
25
S
7
G
1
Posts: 222
Reputation: 3,350

Post » Tue Dec 30, 2014 5:17 pm

FredQ wrote: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.
B
21
S
5
Posts: 196
Reputation: 1,984

Post » Tue Dec 30, 2014 5:45 pm

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"
ImageImage
Mr. Green - Platform/puzzle game out now!
B
25
S
7
G
1
Posts: 222
Reputation: 3,350

Post » Tue Dec 30, 2014 9:59 pm

Looking for reasons to be offended is no way to go through life.
B
21
S
5
Posts: 196
Reputation: 1,984


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 5 guests