This is a little late to the party, but I have been struggling with this for a couple of days. It is possible and none of the answers I found here have worked. It's deceptively simple. Here's the .ajax call:
<!DOCTYPE HTML>_x000D_
<html>_x000D_
<head>_x000D_
<body>_x000D_
<title>Javascript Test</title>_x000D_
<script src="http://code.jquery.com/jquery-latest.min.js"></script>_x000D_
<script type="text/javascript">_x000D_
$(document).domain = 'XXX.com';_x000D_
$(document).ready(function () {_x000D_
$.ajax({_x000D_
xhrFields: {cors: false},_x000D_
type: "GET",_x000D_
url: "http://XXXX.com/test.php?email='[email protected]'",_x000D_
success: function (data) {_x000D_
alert(data);_x000D_
},_x000D_
error: function (x, y, z) {_x000D_
alert(x.responseText + " :EEE: " + x.status);_x000D_
}_x000D_
});_x000D_
});_x000D_
</script> _x000D_
</body>_x000D_
</html>
_x000D_
Here's the php on the server side:
<html>_x000D_
<head>_x000D_
<title>PHP Test</title>_x000D_
</head>_x000D_
<body>_x000D_
<?php_x000D_
header('Origin: xxx.com');_x000D_
header('Access-Control-Allow-Origin:*');_x000D_
$servername = "sqlxxx";_x000D_
$username = "xxxx";_x000D_
$password = "sss";_x000D_
$conn = new mysqli($servername, $username, $password);_x000D_
if ($conn->connect_error) {_x000D_
die( "Connection failed: " . $conn->connect_error);_x000D_
}_x000D_
$sql = "SELECT email, status, userdata FROM msi.usersLive";_x000D_
$result = $conn->query($sql);_x000D_
if ($result->num_rows > 0) {_x000D_
while($row = $result->fetch_assoc()) {_x000D_
echo $row["email"] . ":" . $row["status"] . ":" . $row["userdata"] . "<br>";_x000D_
}_x000D_
} else {_x000D_
echo "{ }";_x000D_
}_x000D_
$conn->close();_x000D_
?>_x000D_
</body>
_x000D_