Ajax Call multiple parameters

Code in my view file:



        url: '".yii\helpers\Url::toRoute("daily-ward-entry/charges-cash")."',

        dataType: 'json',

        method: 'GET',       

        data: {id:$('#dailywardentry-doctor_visit_name').val(),

       room_category:$('#dailywardentry-room_name').val()// Want to use this additional params 


        success: function (data, textStatus, jqXHR) {






And code in my controller is like:

public function actionChargesCash($id){

        $model = \app\models\IpdCharges::findOne(['id'=>$id]);

        return \yii\helpers\Json::encode([





I want to fill the data on the basis of additional parameter room_category:$(’#dailywardentry-room_name’).val() which is not working.

While checking in firefox I am getting the status 200 OK like:

GET http://localhost/hospitalerp/web/index.php?r=daily-ward-entry%2Fcharges-cash&id=1&room_category=6

Still I am getting the values as if the parameter room_category is not supplied.

I think the problem is in the code which needs to be modified -

$model = \app\models\IpdCharges::findOne(['id'=>$id]); 

Here only id is used in find and I don’t know how to add parameter for room_category

Any solution will be greatly appreciated. Thanks.

To add other parameters to findOne just add them as key value pairs to the array.

$model = \app\models\IpdCharges::findOne(['id'=>$id, 'room_category' => $roomCat, 'othercondition' => $other]);