我快疯了,我不知道为什么,但我非常简单的 Jquery 帖子无法正常工作。我有 index.php 和 temp.php 如下。我仍然收到“未返回 OK”,不知道为什么,因为如果我在 if 条件之前发出警报,数据会返回“ok”。
索引.php:
<? session_start(); ?>
<!DOCTYPE HTML>
<meta charset="windows-1250">
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery- ui.css" rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"> </script>
<link rel="stylesheet" type="text/css" href="style.css" />
<script>
function do_post(item)
{
$.post("temp.php", {par:item}, function(data,status){
//alert("Data: " + data + "\nStatus: " + status);
if(data=="ok")
{
alert('RETURNED OK');
//location.reload();
}
else
{
alert('NOT RETURNED OK');
}
});
}
</script>
<body>
<a href="#" onclick="do_post('whatever');">click</a>
</body>
</html>
temp.php:
<? echo "ok"; ?>
提前感谢您的任何想法。