I am posting to a php page using ajax (ignore the data posted, thats not important)
When I run the php page on my linux server using the command: php addHit.php it correctly echoes out the hostname of the remote server. However this does not happen in ajax, all I get is a blank alert where the success function is. You can see it in action here: http://ec2-54-244-169-118.us-west-2.compute.amazonaws.com/bootstrap/jumbotron-narrow/index.php
<script>
$(function() {
$("form[name=addHit]").submit(function() {
alert("I am an alert box!");
var link = $("input[name=link]").val();
var comments = $("input[name=comments]").val();
var datastring = "link="+link+"&comments="+comments;
alert(datastring);
$.ajax({
type: "POST",
url: "/bootstrap/jumbotron-narrow/addHit.php",
data: datastring,
success: function(data, status, xhr) {
alert(data);
},
error: function(httpRequest, textStatus, errorThrown) {
alert("status=" + textStatus + ",error=" + errorThrown);
}
});
alert("here");
return false;
});
});
</script>
my addHit.php page
$commands = "ssh -i adoekey.pem ubuntu@ip-10-250-69-130.us-west-2.compute.internal hostname -f ";
echo exec($commands);