jeudi 28 septembre 2017

error 422 (Unprocessable Entity) in laravel

I have a trouble when show error in laravel. I am using ajax to send request form from client to server and backward. This is my ajax code and seem to be function append() is not working.

$('#petition-form').on('submit', function(e) {
  e.preventDefault();
  var formdata = new FormData($(this)[0]);
  formdata.append('content', tinymce.get('content').getContent());
  $.ajax({
    url: $(this).attr('action'),
    data: formdata,
    processData: false,
    contentType: false,
    cache: false,
    method: 'POST'  
  }).done(function(response) {
   window.location.href = response.slug;
 }).fail(function(response) {
    $(this).append(parseJSON(response));
    // var getError = $.parseJSON(response);
  });

}); when console.log(response) it is array. anyone help me solve that. Thank u



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire