Hi everybody,

We have a simple Statamic contact form and I would like to post the form via Ajax. It's works well but we cannot able to handle the error cases, because we got back the whole rendered page with the errors.

Is there any solution to got back only the fields's errors in a JSON response?

Here is the client side code (this.form variable contains the _params and _token which generated by the form:create tag, this.action value is /!/Form/create )

axios({
    method: 'post',
    url: this.action, 
    data: this.form,
    headers: {
      'Content-Type': 'application/json'
    }
  }).then(response => {
    this.isLoading = false
    this.isSent = true
  }).catch(errors => {
    console.log(errors)
 }
Answered by Barnabas Szekeres! Go to answer.