【发布时间】:2011-10-21 19:21:48
【问题描述】:
我有这个 Jquery Javascript 代码:
$(document).ready(function(){
$("#check_button").click(function(){
$.ajax({
url: "includes/adcontent.php",
type: "GET",
data: "id=<?php echo $id; ?>",
async: false,
cache: false,
beforeSend: function (data) {
$('#check_quest_button_div').html("<img src='/images/icons/loading.gif' title='Please wait' alt='Please wait' />");
}
});
});
});
这是我在 include/adcontent.php 中的 PHP 代码:
if (!isset($id) && isset($_GET['id'])){
$id=htmlspecialchars(strip_tags($_GET['id']));
}
echo $id;
但是使用此代码时,我会收到一条错误消息。该脚本不发送 GET 数据。有什么问题?
【问题讨论】:
-
不要作为数据传递,作为查询参数传递(在includes/adcontent.php后添加
?id=<?php echo $id; ?> -
您能对其进行wireshark 并确保正在发出请求吗?
-
是的,请求正常。如果我放置代码 echo "ok";,我可以看到它。
-
这是我的错误:未定义的变量:id 我还可以看到 GET 是空的:[_GET] => Array ()