How do I send an AJAX request header 4 cross domain access?

Get help using Construct 2

Post » Sat Sep 02, 2017 11:02 pm

The manual states to:

If you want AJAX requests to your server to work from any domain, or in preview, you can configure it to send the following HTTP header:
Access-Control-Allow-Origin: *

it is not clear to me what goes where when setting this up? This does not work.

Parameters for AJAX: Set request header
Header "Access-Control-Allow-Origin:*"
Value ""

How exactly should I be filling this out?
B
11
S
1
Posts: 7
Reputation: 1,261

Post » Sat Sep 02, 2017 11:26 pm

You have to set it in PHP file. The other way is to make a .htaccess file with the following content:

Code: Select all
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>


Place this file on the server next to the file you are trying to access with AJAX.
ImageImageImage
B
28
S
16
G
82
Posts: 1,030
Reputation: 45,804

Post » Sun Sep 03, 2017 12:46 am

thank you for your response.

If that is the only way then why does the AJAX plugin have the "set request header" action?

All I am after is a real example of how to do this action's parameters.

If I understand your response then:

Header "Access-Control-Allow-Origin"
Value "*" should work.

It does not.
B
11
S
1
Posts: 7
Reputation: 1,261

Post » Tue Sep 05, 2017 4:52 pm

You have to set the header in the response from the server. So your code needs to be in your server-side code... not in Construct.

Like this:Image
https://www.ravenheart.ca/home
I don't check the forums much anymore, but I will receive an email for PMs.

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
23
S
6
G
1
Posts: 1,419
Reputation: 4,857


Return to How do I....?

Who is online

Users browsing this forum: blackhornet and 25 guests