我的 eventinfo.php 给出以下输出:
<br />
<b>Notice</b>: Undefined index: club in <b>/homepages/19/d361310357/htdocs/guestvibe/wp-content/themes/yasmin/guestvibe/eventinfo.php</b> on line <b>11</b><br />
[]
HTML (index.php):
<select name="club" class="dropdown" id="club">
<?php getClubs(); ?>
</select>
jQuery (index.php):
<script type="text/javascript">
$(document).ready(function() {
$.ajax({
type: "POST",
url: "http://www.guestvibe.com/wp-content/themes/yasmin/guestvibe/eventinfo.php",
data: $('#club').serialize(),
success: function(data) {
$('#rightbox_inside').html('<h2>' + $('#club').val() + '<span style="font-size: 14px"> (' + data[0].day + ')</h2><hr><p><b>Entry:</b> ' + data[0].entry + '</p><p><b>Queue jump:</b> ' + data[0].queuejump + '</p><br><p><i>Guestlist closes at ' + data[0].closing + '</i></p>');
},
dataType: "json"
});
});
$('#club').change(function(event) {
$.ajax({
type: "POST",
url: "http://www.guestvibe.com/wp-content/themes/yasmin/guestvibe/eventinfo.php",
data: $(this).serialize(),
success: function(data) {
$('#rightbox_inside').hide().html('<h2>' + $('#club').val() + '<span style="font-size: 14px"> (' + data[0].day + ')</h2><hr><p><b>Entry:</b> ' + data[0].entry + '</p><p><b>Queue jump:</b> ' + data[0].queuejump + '</p><br><p><i>Guestlist closes at ' + data[0].closing + '</i></p>').fadeIn('500');
},
dataType: "json"
});
});
</script>
我可以从 jQuery 运行警报,因此它处于活动状态。
我已经从旧版本的网站上复制了这个,但是我已经更改了文件结构(通过移动到 WordPress)所以我怀疑这些变量可能甚至没有首先到达 eventinfo.php ......
index.php 在 wp-content/themes/cambridge 和 eventinfo.php 在 wp-content/themes/yasmin/guestvibe 但我试图通过完整引用 URL 来避免结构问题。
有任何想法吗?
编辑
抱歉,忘记了 eventinfo.php。我怀疑只有第 3 行是相关的,但我可能错了。
include('functions.php');
connect();
$night = $_POST['club'];
$night = mysql_real_escape_string($night);
$query = "SELECT * FROM nights WHERE name = '" .$night. "'";
$result = mysql_query($query);
$items = array();
if($result && mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_array($result)) {
$items[] = array("entry"=>$row['entry'], "day"=>getLongDateString($row['day']), "queuejump"=>$row['queue jump'], "closing"=>$row['closing']);
}
}
mysql_close();
// convert into JSON format and print
echo json_encode($items);
?>
vardump[$_POST] 给出:
array(0) {
}