Reputation: 121
I'm playing around with AJAX requests to a php file via jQuery, and I'm getting some strange output.
main.php
:
<!DOCTYPE html>
<head>
<link rel="stylesheet" href="/stylesheets/style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</head>
<body>
<?php
include('main.html');
?>
<script type='text/javascript'>
$('#startButton').click(function() {
$.ajax({
method: "POST",
url: "test.php",
}).done(function(data) {
alert(data);
});
});
</script>
</body>
test.php
:
<?php
echo 'Hello';
?>
Instead of alerting 'Hello' on button click, my program alerts the html of main.php
. Any idea what's going on?
Upvotes: 1
Views: 42
Reputation: 121
Figured it out - I'm using GoogleAppEngine and my app.yami
file was not configured to direct requests to test.php
, as it defaults all requests to main.php
, hence the returned html.
Apologies for not stating that I was using GAE - I didn't think it was relevant.
Credit to @Dagon for suggesting that it was a redirecting error which led me to the correct answer.
Upvotes: 1