title: delete function in yii controller
body: <p>How do i get the delete button to work in Yii? These are my controller and view and i have a custom delete button.</p>
  
  <pre><code>public function actionDelete($id)
  
  {
      $model = $this-&gt;loadModel($id);
      $model-&gt;DeletedItem = 1;
  
  $model-&gt;save();
  
      echo"success";
      if(!isset($_GET['ajax']))
      $this-&gt;redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
  
  }
  </code></pre>
  
  <p>and my view is:</p>
  
  <pre><code>function Delete(Iid,Itype){
  
      if(type=="a")
      {
          console.log("Assignment");
          $.ajax({
              type: 'GET',
              //data: Iid,
              url:  '/grade/delete/' + Iid,
              success: function (data) {
                  console.log(data);
                  //$.fn.yiiGridView.update('Assignment-grid');
              }
      });
  </code></pre>