How do I fix this AJAX request?

Just started using Construct 2? Post your questions here

Post » Sat May 17, 2014 3:45 pm

Hello,

The AJAX request actually give nothing.
Well, it was working and after changing few things, not working anymore...

Did I made a mistake somewhere?

leaderproblem.jpg


1. The URL is right, text is display
2. Object are write and good position
3. The capx is bit big to send it.


Thank you !
You do not have the required permissions to view the files attached to this post.
B
15
S
4
Posts: 57
Reputation: 1,792

Post » Thu May 22, 2014 12:34 pm

Have you try after export project ?
B
13
S
3
G
2
Posts: 49
Reputation: 1,675

Post » Thu May 22, 2014 12:37 pm

yeah Finally I export the game and hosted it then it works... But I am so surprised it worked once Oo
B
15
S
4
Posts: 57
Reputation: 1,792

Post » Thu May 22, 2014 12:43 pm

I think it is because of the local .

https://www.scirra.com/manual/107/ajax

Making AJAX requests cross-domain or in preview
By default, browsers block AJAX requests across domains. This means, for example, a game on scirra.com can request other pages on scirra.com, but cannot request pages on facebook.com. This is an important security feature of web browsers (it is not specific to Construct 2 or its AJAX object).

Also, when previewing in Construct 2 the game runs on localhost. This counts as a different domain to the rest of the internet, so typically AJAX requests to any web page will fail during preview, unless the server explicitly allows cross-domain requests.

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: *

This will enable AJAX requests from any domain, but you should still be aware of the possible security implications of this. For more information on cross-domain requests see HTTP access control on MDN.
B
13
S
3
G
2
Posts: 49
Reputation: 1,675


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 7 guests