title: Why I'm not able to print the error messages in AJAX response?
body: <p>I've following HTML code:</p>
  
  <pre><code>&lt;a href="#" id="promotion_status_1"&gt;
      &lt;button type="button" class="btn btn-default brmodalbtn" data-toggle="modal" data-target="#BrandImageModal" id="1"&gt;On&lt;/button&gt;
  &lt;/a&gt;
  
  &lt;div class="container"&gt;
    &lt;div class="modal fade" id="BrandImgeModaal"&gt;
      &lt;div class="modal-dialog"&gt;
        &lt;div class="modal-content"&gt;
          &lt;form id="form" enctype="multipart/form-data" role="form"&gt;
            &lt;input type="text" class="form-control" name="brand_id" id="brand_id" value="{$data.id}"&gt;
            &lt;input type="text" name="admin_url" id="admin_url" value="http://localhost/abc.com"&gt;    
            &lt;input type="text" name="op" value="upload_brand_image"&gt;    
            &lt;div class="modal-header"&gt;
              &lt;button type="button" class="close" data-dismiss="modal"&gt;&lt;span aria-hidden="true"&gt;&amp;times;&lt;/span&gt;&lt;span class="sr-only"&gt;Close&lt;/span&gt;&lt;/button&gt;
              &lt;h4 class="modal-title"&gt;Brand Image&lt;/h4&gt;
            &lt;/div&gt;
            &lt;div class="modal-body"&gt;
              &lt;div id="messages"&gt;&lt;/div&gt;
              &lt;input type="file" name="file" id="file"&gt;
            &lt;/div&gt;
            &lt;div class="modal-footer"&gt;
              &lt;button type="submit" class="btn btn-primary"&gt;Save&lt;/button&gt;
              &lt;button type="button" class="btn btn-default" data-dismiss="modal"&gt;Close&lt;/button&gt;
            &lt;/div&gt;
          &lt;/form&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>jQuery AJAX Code :</p>
  
  <pre><code>$('#form').submit(function(e) {
    var form = $(this);
    var formdata = false;
    if(window.FormData) {
      formdata = new FormData(form[0]);
    }    
    var formAction = form.attr('action');
  
    $.ajax({
      type        : 'POST',
      url         : 'manufacturers.php',
      cache       : false,
      data        : formdata ? formdata : form.serialize(),
      //data      : formdata ? formdata : form.serialize() + '&amp;' + $.param({'op':'upload_brand_image'}),
      contentType : false,
      processData : false,
  
      success: function(response) { alert(response); return;
        if(response.error == 1) {             
          $('#BrandImageModal').modal('hide');
        } else { 
          $('#messages').addClass('alert alert-danger').text(response);
        }
      },
      dataType:"JSON"
    });
    e.preventDefault();
  });
  </code></pre>
  
  <p>PHP Code:</p>
  
  <pre><code>$request = $_REQUEST ;
  switch( $op ) {
      case "upload_brand_image":
  
        $ret = $objManufacturer-&gt;UploadBrandImage($request, $_FILES, $allowed_image_extension, $manuf_error_messages);
  
        if(!$ret) { 
          $error_msg = $objManufacturer-&gt;GetAllErrors();
  
          $response = array(
            "error" =&gt; 1,
            "error_message" =&gt; $error_msg
          );
  
          echo(json_encode($response));
        } else {        
          if(!empty($_FILES['file']['name'])) {
            upload_file_now( $_FILES['file'], $brand_image_path, $t, $brand_name, $ext);          
          }      
        }
        die;
        break;
    }
  </code></pre>
  
  <p>The <code>$error_msg</code> array contains following content :</p>
  
  <pre><code>Array
  (
      [domain_id] =&gt; Please select domain
      [brand_name] =&gt; Brand name can't be blank
      [brand_name_invalid] =&gt; Brand name is not valid, it should be alphabetic
      [email] =&gt; Brand email can't be blank
      [email_invalid] =&gt; Brand email is not valid
      [brand_image] =&gt; Brand image can't be blank
      [brand_image_format] =&gt; Please upload brand image in a proper format
      [brand_image_size] =&gt; Brand image size is greater than 5 MB
      [brand_image_dimesnions] =&gt; Only upload brand image having dimensions &gt;= 940 X 370 px
      [details] =&gt; Brand details can't be blank
  )
  </code></pre>
  
  <p>I'm not able to print the messages contained in this array in bootstrap modal. </p>
  
  <p>Where I'm doing wrong? Would someone please help me in this regard?</p>
  
  <p>Thanks</p>