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

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


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.

Popular posts from this blog

Visual Studio Code: How to configure includePath for better IntelliSense results

Spring cloud config client Could not locate PropertySource

Makefile test if variable is not empty