how to retrieve data from database through ajax against specific id in yii2 framwork

Multi tool use


how to retrieve data from database through ajax against specific id in yii2 framwork
_form.php
<?= $form->field($vehicle, 'vehicleRegistrationNumber')->textInput(['maxlength' => true, 'id'=> 'regNum']) ?>
Ajax code
$.ajax({
type:'POST',
cache:false,
data:{regNum:regNum},
url: "<?php echo Url::toRoute('appointments/regAjax.php')?>",
succes: function(response){
console.log('success');
}
});
AppointmentsController
public function actionRegAjax()
{
if(Yii::$app->request->isAjax){
$data= Yii::$app->request->post();
}
}
regAjax.php
<?php
$regNum = $_POST['regNum'];
echo json_encode($regNum);
?>
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.