環境
- 前端Layui
- 后端Thinkphp5
js代碼
<script>
layui.use(['form', 'table'], function () {
table.on('tool(currentTableFilter)', function (obj) {
var data = obj.data;
if (obj.event === 'delete') {
layer.confirm('真的刪除行么', function (index) {
obj.del();
layer.close(index);
var student_id = JSON.stringify(obj.data.id);
window.location = "index.php?s=index/index/index&student_id=" + student_id;
});
}
});
});
</script>
php代碼
public function index()
{
// $student_id = $_REQUEST['student_id'];
$student_id = Request::instance()->get('student_id');
echo $student_id;
}
使用GET方法傳參,相較於POST,
- 請求更快
- GET傳輸的數據在 URL 中對所有人都是可見的
- 有長度限制(URL 的最大長度是 2048 個字符)
- ......