//删除记录
$(".delete").click(function () {
var id = $(this).data('id');//7
var name = $(this).data('name');
la
btn: ['确定','取消']
},function () {
//alert(id); 7
$.ajax({
type : "DELETE",
url : "{:url('delete')}",
data : {data:id},
success : function (res) {
}
});
});
});
/**
* 删除指定资源
*
* @param int $id
* @return \think\Response
*/
public function delete($id)
{
if (request()->isDelete()){
//echo $id; 'delete'
dump(input('param.'));die;
/*array (size=2)
'data' => string '7' (length=1)
'id' => string 'delete' (length=6)*/
}
}
这里的$id打印出来是'delete'字符串, 如果前端ajax那里设置为{id:id}就无法获取到id的值,因为在php这边,永远显示的是’delete‘,请问有人知道怎么回事吗
最佳答案