I've been stumped on this for a few days and have looked at a number of different posts without much luck.
I make an AJAX call using jQuery like so:
console.log("Sending post request");
  var postData = {
    "function": "connectToGame",
    "name" : name,
  };
  console.log(postData);
  $.ajax({
    type: "POST",
    url: 'http://localhost:8000/Cordova/server/database.php',
    data: postData,
    dataType: 'text',
    success: function(data)
    {
      console.log("AJAX Success! See return:");
      console.log(data);
      var id = data[0];              //get id
      console.log('Server returned: ' + id + ' as the id');
    },
    error: function(e){
      console.log("AJAX Failure!");
      console.log(e);
    }
  });
After removing a lot of code trying to narrow down the problem, my server/database.php currently looks like this:
<?php
echo "1";
?>
After making the AJAX call the console shows this:
database.js:21 Sending post request
database.js:26 Object {function: "connectToGame", name: ""}
database.js:34 AJAX Success! See return:
database.js:35 <?php
echo "1";
exit;
?>
database.js:38 Server returned: < as the id
I am completely stumped as to why the AJAX call is returning the entire PHP file and any help would be greatly appreciated.
 
     
     
     
    