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: *
You can add this in preview now!? How does one go about setting this?
I have tried but I still have the same problem. I have a sample capx and I exported it to a HTML5 version.
The project requests a PHP on a server that gets some values from a database. As you can see, when you run the capx, you can successfully see those values. If you run it on the exported version, there is an error. The requested PHP opens with
<?php
header('Access-Control-Allow-Origin: *');[/code:363dlih1]
Make sure you can access the URL in a normal browser first, i.e. just type in the AJAX url into your browser and see what happens. You can always use the net tab of the debug tools to track the AJAX request and see why it failed.
These are the requests from your live HTML5 app, and none of them failed. So all of the calls here are working fine. Is your C2 interpreting the reply appropriately?
Second observation, and probably why it is not working. Your "Access-Control-Allow-Origin: *" header never made it into your response headers. So your PHP is bad.