不返回任何东西,这是对Ajax的简单的测试,我想送我的index.php变量t,让我process.php和警报数字15的数据(T),当我点击链接,但我的问题是没有任何警告在阿贾克斯
这是我的index.php
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="jquery-3.2.1.min.js"></script>
<script>
$(document).ready(function() {
var t = 10;
$("#btn").click(function() {
$.ajax({
type:'post',
url:'process.php',
data:{
't':t
},
success:(function (response) {
alert(response);
}
})
})
})
</script>
<button id="btn">Click!</button>
这是我process.php像下面
<?php
$res = $_POST['t'] + 5;
return $res
?>
你得到任何错误控制台?也可以尝试添加'error:function'并查看你得到的错误 –
您可以指向任何**在PHP中使用“return”而不是输出内容来生成页面响应的示例吗?发布前请详细研究。 –
你需要养成[接受答案](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work)的习惯,它可以帮助你解决你的问题。您将获得积分,其他人将被鼓励帮助您。 –