我的简单测试代码存在问题。在远程服务器上一切都很好,它在我移动到localhost(xampp)
时启动我有一个页面:
http://localhost/test/test.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>NeedNext - Try It</title>
<script type="text/javascript" src="javascript/jquery.js" ></script>
<script type="text/javascript">
$().ready(function() {
$("#listinx").load("ajax.php",{variable : "WTF"})
});
</script>
</head>
<body>
<div id="listinx"></div>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>NeedNext - Try It</title>
<script type="text/javascript" src="javascript/jquery.js" ></script>
<script type="text/javascript">
$().ready(function() {
$("#listinx").load("ajax.php",{variable : "WTF"})
});
</script>
</head>
<body>
<div id="listinx"></div>
</body>
</html>
包含:
<?php
echo "heh?";
echo $variable;
?>
我认为浏览器中的结果应该是:“嘿?WTF”,但它只是“嘿?”。有什么想法有什么不对吗? 请告诉我, 谢谢, 米哈尔
答案 0 :(得分:1)
您没有启用register_globals
因此,您不能通过编写$variable
隐式获取POST参数。
将您的代码更改为echo $_POST['variable']
。
您还应该在服务器上禁用它:
警告
自PHP 5.3.0起,此功能已 DEPRECATED 。非常不鼓励依赖此功能。
通常会产生安全漏洞。
答案 1 :(得分:0)
你试过了吗?
echo $_REQUEST['variable'];