title: Displaying text from ajax call which is passed from controller
body: <p>I'm struggling to put my error msg "From date must be set before to date", through controller to ajax call. Error message needs to be displayed in div as warning. Code below does not work.</p>
  
  <p>Controller:</p>
  
  <pre><code> $response_array['error'] = [trans('servicereports.errors.to_date')];
   return json_encode($response_array);
  </code></pre>
  
  <p>Result: </p>
  
  <blockquote>
    <p>{"error":["From date must be set before to date."]}</p>
  </blockquote>
  
  <p>Ajax:</p>
  
  <pre><code> $.ajax({
              type: 'POST',
              url: '{{ route('einsight.servicereports.validateDates') }}',
              cache: false,
              data: $(this).serialize(),
              error: function(msg, result) {                    
                  var data = jQuery.parseJSON(result);
                  $.each(data, function(index, value) {
                      $("#error-message").append( value );
                  });
  
              }
          });
  </code></pre>
  
  <p>Div for displaying messages:</p>
  
  <pre><code>&lt;div class="flash-message" id="error-message"&gt;               
  &lt;/div&gt;
  </code></pre>