json - 使用PHP成功提交时未显示的表单成功消息

I have difficulty in showing success message on form. Its showing all the error messages but not the success message.

On controller file its showing when I comment $this->model_catalog_outofstockquery->addQuery($this->request->post); but this line is necessary.

On submitting form the entries are successfully loading to the database.

I have already call model from the constructor

My code on controller file is-

    public function write() {
        $this->load->language('product/outofstock_enquiry');

        $json = array();

        if ($this->request->server['REQUEST_METHOD'] == 'POST') {

            if ((utf8_strlen($this->request->post['name']) < 3) || (utf8_strlen($this->request->post['name']) > 25)) {
                $json['error'] = $this->language->get('error_name');
            }
            if (!filter_var($this->request->post['email'], FILTER_VALIDATE_EMAIL)) {
                $json['error'] = $this->language->get('error_email');
            }
            if ((!filter_var($this->request->post['quantity'],FILTER_VALIDATE_INT))) {
                $json['error'] = $this->language->get('error_quantity');
            }            

                if (!isset($json['error'])) {            
                $json['success'] = $this->language->get('text_success');
                    $data['product_id'] = $this->request->post['product_id'];
                    $data['product_name'] = $this->request->post['product_name'];
                    $data['name'] = $this->request->post['name'];
                    $data['email'] = $this->request->post['email'];
                    $data['quantity'] = $this->request->post['quantity'];
                    $data['notify'] = 0;
                    $this->model_catalog_outofstockquery->addQuery($this->request->post); 
                }

        }

        $this->response->addHeader('Content-Type: application/json');
        $this->response->setOutput(json_encode($json));
    }

The script on the view file under the form is

<script type="text/javascript"><!--
  $('#button-submit').on('click', function() {
    $.ajax({
      url: 'index.php?route=product/outofstock_enquiry/write&product_id=<?php echo $product_id; ?>',
      type: 'post',
      dataType: 'json',
        data: 'name=' + encodeURIComponent($('input[name=\'name\']').val()) + '&email=' + encodeURIComponent($('input[name=\'email\']').val()) + '&product_name=' + encodeURIComponent($('input[name=\'product_name\']').val()) + '&quantity=' + encodeURIComponent($('input[name=\'quantity\']').val()) , 

      data: $("#form-ask").serialize(),
      beforeSend: function() {
        $('#button-submit').button('loading');
      },
      complete: function() {
        $('#button-submit').button('reset');
      },
      success: function(json) {
        $('.alert-success, .alert-danger').remove();

        if (json['error']) {
          $('#outofstock_enquiry').after('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + '</div>');
        }
        if (json['success']) {
          $('#outofstock_enquiry').after('<div class="alert alert-success"><i class="fa fa-check-circle"></i> ' + json['success'] + '</div>');

          $('input[name=\'name\']').val('');
          $('input[name=\'email\']').val('');
          $('input[name=\'product_name\']').val('');
          $('input[name=\'quantity\']').val('');
          $('input[name=\'product_id\']').val('');                      
        }
      } 
    });
  });
//--></script>