How do I get ajax to work

Get help using Construct 2

Post » Tue Jun 20, 2017 5:57 pm

Funny, I tried with other browsers than IE11, and it's not working with them. The response is blocked because of the Access-Control-Allow-Origin only allowing "http://www.mywebbnerd.com". Why this works in IE and not in other browser is beyond me, I thought the CORS mechanism was server-side.

edit: Ok, after a bit of reading, it seems that CORS is only for a user's safety... so I guess that it makes sense that it only works in IE. :lol: Turns out the Origin request is not set by IE (in my scenario at least), thus the Access-Control-Allow-Origin has no effect.
B
74
S
31
G
26
Posts: 994
Reputation: 20,198

Post » Tue Jun 20, 2017 10:35 pm

I just tried reaching your file with ajax and it seems that it actually is CORS that blocks the access. Since you included it in the file it is potentially overridden by the server.

You can try to upload a htaccess file. Write the stuff below into a textfile, rename it to ".htaccess" (without "") and drop it next to your php files. Or ask the hoster. For testing, you can also disable the CORS in Chrome.
Code: Select all
<FilesMatch ".(php)">
   Header set Access-Control-Allow-Origin "*"
</FilesMatch>


Or you can switch the hoster ofc :roll: There´s some pretty cheap ones out there.
B
16
S
3
Posts: 69
Reputation: 1,048

Post » Thu Jun 22, 2017 4:08 am

Switched host and it works like a charm, thanks guys!
B
23
S
11
G
4
Posts: 69
Reputation: 3,439

Previous

Return to How do I....?

Who is online

Users browsing this forum: koops and 7 guests