Hello World!
Это сделка, я создаю сайт, где люди могут размещать вакансии и другие, чтобы делать ставки на них
Просмотр
<button id="hire" class="btn btn-group-sm btn-danger hireHim" value="<?= $idBidder?>" formmethod="post"> hire him</button>
Ajax
$('.hireHim').on('click',function()
{
$.ajax({
url : '$hireUrl',
type: 'POST',
dataType: 'json',
data: {
'id' : $(this).attr(' value '),
},
success: function(data) {
$('.hireHim').hide(200);
},
});
});
AjaxController
public function actionBidstatus($id)
{
$result['result'] = false;
$model = $this->findModel($id);
$model->status = 1;
$model->save(false);
$result['result'] = true;
json_encode($result);
}
private function findModel($id)
{
$r = Bids::find()
->where(['id'=> 87])
->one();
return $r;
}
Скажите, пожалуйста, что вы думаете или как лучше всего это сделать?