我正在通过jQuery处理AJAX对php文件的请求,并且得到了一些奇怪的输出。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';
?>
我的程序不是在单击按钮时提醒“ Hello”,而是提醒
main.php
的html。知道发生了什么吗? 最佳答案
弄清楚了-我使用的是GoogleAppEngine,我的app.yami
文件未配置为将请求定向到test.php
,因为它默认将所有请求定向到main.php
,因此返回了html。
很抱歉没有声明我正在使用GAE-我认为这并不重要。
感谢@Dagon暗示这是一个重定向错误,使我得到了正确的答案。