View urlCreate code
$ajaxSaveTestGrid = Yii::$app->urlManager->createUrl('testgrid/ajaxsave');
This Is My View Ajax Code
function saveRow(id, index) {    
    if(id == 'tbl_testGrid') {                
        save(id, index);
    }
 }
function save(id, index) {
    var testGrid_name = $('#testGrid_name' + index).val();
    var testGrid_qty = $('#testGrid_qty' + index).val();
    var testGrid_price = $('#testGrid_price' + index).val();
    var url = '$ajaxSaveTestGrid';
       // alert(testGrid_name+testGrid_qty+testGrid_price);
    $.ajax({
        type: 'GET',
        url: url,
        data: {
                testGrid_name:testGrid_name, 
                testGrid_qty:testGrid_qty,
                testGrid_price:testGrid_price
              },
        contentType: 'application/json; charset=utf-8', 
        dataType: 'json',
        success: function (response) { 
            if(response == 'error') {
                alert('Fail to save! Please try again'); 
            } else {   
                $('#testGrid_name' + index).attr(\"disabled\",true);             
                $('#testGrid_qty' + index).attr(\"disabled\",true); 
                $('#testGrid_price' + index).attr(\"disabled\", true); 
                $('#testGrid_save_button' + index).attr(\"class\", \"hidden\"); 
                $('#testGrid_delete_button' + index).attr(\"class\", \"hidden\"); 
                $('#testGrid_edit_button' + index).attr(\"class\", \"show\");  
                $('#hid_testGrid_id' + index).val(response[0].testgrid.id);
                $('html,body').animate({scrollTop: $('#btn_testGrid').offset().top});
            }
        }
   });
}
This is my Controller
public function actionAjaxsave() {
    $result = array();
    $testGrid_name = $_GET['testGrid_name'];
    $testGrid_qty = $_GET['testGrid_qty'];
    $testGrid_price = $_GET['testGrid_price'];
    $model = new Testgrid();
    $model->name = $testGrid_name;
    $model->price = $testGrid_price;
    $model->qty = $testGrid_qty;
    if ($model->save()) {
        array_push($result, ['testgrid' => $model]);
        $result = Json::encode($result);
        echo $result;
    } else {
        echo 'error';
    }
}
It occurring Internal Server Error
I want to save json Data to model.
 
     
     
    