I'm using yii2 and a newbie in JavaScript and ajax.
I am getting this error:
jquery.js:9175 POST http://localhost/istanagroup/web/purchase-order/basepricenet 500 (Internal Server Error)
here is the controller function
public function actionBasepricenet(){
$id = $_POST['id'];
$model = MasterItem::find()->andFilterWhere(['id_master_item'=>$id])->one();
echo $model;
here is the js :
$('#purchaseorderdetail-0-id_master_item').change(function(){
var cat = $(this).val();
$.ajax({
type:'POST',
url:'http://localhost/istanagroup/web/purchase-order/basepricenet',
data : {id:cat},
dataType : 'text',
success:function(res){
console.log(res);
$('#purchaseorderdetail-0-base_price').val(res);
}
});
});