How do I AJAX - Access-Control-Allow-Origin: *

Get help using Construct 2

Post » Sat Apr 12, 2014 3:17 pm

I'm trying to pull a large database as a JSON file from a website using the AJAX plug-in.

I've copied the text bellow from the Construct 2 AJAX Plug-in Reference page in the manual.

Making AJAX requests cross-domain or in preview:
"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: *"

The manual fails to mention how this is executed.

Exactly how do I configure an AJAX request to send a HTTP header such as "Access-Control-Allow-Origin"
B
7
S
1
Posts: 43
Reputation: 513

Post » Sat Apr 12, 2014 4:00 pm

You're probably better off using Google for getting info on this as from what I can gather (those who know please feel free to put me right) you will need to configure the server to allow this.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
134
S
30
G
84
Posts: 5,386
Reputation: 58,454

Post » Sat Apr 12, 2014 5:42 pm

Thats why i'm here, I can't find a solution that will allow construct to do this, because construct is whats going to have to send the header wrapped in it's ajax GET request. Realistically I need to have construct send its AJAX GET request with an Authorization key and instruction for the browser to access "cross domain".

At this stage I'm leaning towards trying to use the XML plug-in instead as I'm assuming you can write your own AJAX GET request will all the information required.

However I can't see a way to import a JSON file and then populate and array using the imported JSON file data. This is paramount because there are over 100 elements each containing over 30 properties. I am not about to embark on manually populating my array with over 3000 entries which are subject to change at any time.

The website I've been authorized to pull the data from keeps their database up to date and complete. Using their JSON file is the only way I can build my app and export it to android in a timely and viable manner.
B
7
S
1
Posts: 43
Reputation: 513

Post » Sun Apr 13, 2014 1:38 pm

it's unfortunately not a construct issue but a server issue. from my understanding, the test mode creates a localhost server and the browser pulls from that... however the browser does not allow one server to redirect to another server without a specific command.

the long term solution is that when you host it, it will pull data from its own servers, and then this issue will not arise.
however I haven't seen an easy-to-understand solution for testing in development mode. I upload to my server but it is awkward.

please Ashley.. this is something that should be fixable by Construct for testing purposes.. it would make server/client testing much much easier.

R
B
7
S
3
G
1
Posts: 184
Reputation: 1,352


Return to How do I....?

Who is online

Users browsing this forum: evillair and 11 guests