0

I'm trying to update a mySQL database using variables from Server A and PHP at Server B. I have access to both servers.

Here's my jQuery on server A.

$.post( "http://xxx/xxx/xxx/update.php", { vote:currentVote, page:pageURL, round:roundNumber });

When I inspect it in Firebug, the console shows the POST with a 200 OK and when I click on the console the Parameters show up correctly.

I've updated my crossdomain.xml.

Here's my php code on server B. When I run the php file alone with manual variables, everything works as expected and the variables are inserted into the database just fine. When I comment them out like I did below, and rely on the $_POST, nothing happens.

//1. Get variables we need from those posted.
$page = $_POST['page'];
$round = $_POST['round'];
$vote = $_POST['vote'];

//$page = "r1m11";
//$round = "1";
//$vote = "Test Restaurant";

A few questions:

  1. Are there any glaring errors in the code that might prevent this from working?
  2. For troubleshooting, is there an easy way to test that the crossdomain policy is working?

Thanks!

Edit: I didn't know what CORS was but the answer was on that page marked as a duplicative post. I just needed to add...

header("Access-Control-Allow-Origin: http://www.website.com");
Layne
  • 642
  • 1
  • 13
  • 32
  • Does server B return proper CORS headers? I expect your browser to be giving you a `SAME ORIGIN POLICY` error. This would clearly indicate that your crossdomain policy isn't working. – Kevin B Mar 11 '14 at 21:49
  • possible duplicate of [CORS with php headers](http://stackoverflow.com/questions/8719276/cors-with-php-headers) – Populus Mar 11 '14 at 21:50
  • I think crossdomain.xml is a flash thing.. – enapupe Mar 12 '14 at 02:25
  • @enapupe I think you are right. The last time I tried this was in Flash... a long time ago. – Layne Mar 12 '14 at 02:38

0 Answers0