Hello Requinix. I think I'm getting closer. Now instead of the alert box I just get NULL to show up in the divContainer.
here is proxy.php:
<?php
if (!isset($_GET['url']))
{
die();
}
$url=urldecode($_GET['url']);
$url='http://' . str_replace('http://','',$url);
echo file_get_contents($url);
?>
and here is my HTML file:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<title>TEST PAGE</title>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
getJSON = function() {
var resultDiv = $("#resultDivContainer");
resultDiv.html('Loading...');
var request = {
version: "0.4",
game: "XXXXXXXXX",
platform: "XXXXXXXXX",
userId: "XXXXXXXXX",
password: "XXXXXXXXX",
data: {}
};
$('#sendInput').val(JSON.stringify(request));
resultDiv.html(console.log('Sending: ' + $('#sendForm').serialize()));
$.ajax({
url: "proxy.php?url=XXXXXXXXX",
type: "POST",
data: $('#sendForm').serialize(),
dataType: "json",
success: function (result) {
var resultString = JSON.stringify(result);
console.log('Result: ' + resultString);
resultDiv.html(resultString);
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
});
};
</script>
</head>
<body>
<h1>Test Page</h1>
<form id="sendForm" action="post"><input id="sendInput" type="hidden" name="json" value="empty" /></form>
<div id="resultDivContainer"></div>
<button type="button" onclick="getJSON()">JSON</button>
</body>
</html>
As I said it appears to communicate with the servlet... and just enters null into the resultDivContainer and the browser javascript log says sending blah blah blah and result: null. Thanks for the help so far and hopefully with your help I can get this going.