【发布时间】:2016-09-24 15:09:48
【问题描述】:
我想从控制器函数中的 ajax 调用中获取一个值。我该怎么做?
我的代码在这里:
<a href="javascript:void(0)" onclick="amount_pay('{{ $res->id}}');"><i class="fa fa-pencil-square-o"></i></a>
我的脚本:
<script>
function amount_pay(id)
{
$.ajax({
type: 'POST',
url: 'amount_popup/'+ id,// calling the file with id
success: function (data) {
alert(1);
}
});
}
</script>
我的路线:
Route::post('amount_popup/{id}', 'AdminController\AmountController@amount_to_pay');
我的控制器功能:
public function amount_to_pay($id)
{
echo $id;
}
【问题讨论】: