【发布时间】:2015-12-23 21:38:27
【问题描述】:
我曾经根据表格进行过反击。一切都很好,直到我不得不在网站上进行更改。
旧代码:
<?php
if( isset($_POST['b1']) ) {
$count += 1;
$_SESSION['count'] = $count;
}
(...)
?>
<form action="start.php" method="post">
<button id="b1" class="btn" name="b1"> B1 </button>
<button id="b2" class="btn" name="b2"> B2 </button>
</form>
表格有问题,所以我正在寻找另一种解决方案。有人告诉我我尝试了 Ajax ,但它只适用于我 $_GET (我需要发布)
我做错了什么?
<script>
$(document).ready(function(){
$("#b1").click(function(){
$.post("start.php", { name: "b1" });
location.reload();
});
});
</script>
【问题讨论】:
-
检查错误和开发者的控制台。
-
更改
{ name: "b1" }->{ b1: 1 }