Ajax submission leads to => An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (2 MB) that this server supports So i'm trying to submit a form using ajax, in my form i have the following:

        $form['actions']['#type'] = 'actions';
        $form['actions']['submit'] = array(
        '#type' =&gt; 'submit',
        '#value' =&gt; $this-&gt;t('OK'),
        '#button_type' =&gt; 'primary',
        '#prefix' =&gt; '&lt;div class="tc btn_pay relative"&gt;',
        '#suffix' =&gt; '&lt;/div&gt;
                        &lt;/div&gt;',
        '#attributes' =&gt; array(
            'class' =&gt; array('proximabold', 'tc', 'transition', 'no-underline', 'ph3', 'pv2', 'mb2', 'dib', 'white'),
        ),
        '#ajax' =&gt; [
            'event' =&gt; 'click',
            'callback' =&gt; '::updateTable',
            'wrapper' =&gt; 'table-wrapper',
            'progress' =&gt; [
                'type' =&gt; 'throbber',
                'message' =&gt; t('Verifying entry...'),
            ],
        ],
    );


and a simple updateTable function:

public function updateTable(array $form, FormStateInterface $form_state) {
    return "Hello World";
}


But when i click on submit i get the error:
An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (2 MB) that this server supports.

I knew that the error is server side (Maybe i'm wrong), so i went to php.ini (i use PHP7) and update the following lines:

post_max_size = 6144M
memory_limit = 6144M
upload_max_filesize = 6144M
max_file_uploads = 1000


but without luck, this configuration shouldn't be necessary as the request size is only 1.5KB
So after a throughout debugging i finally found the solution. the first thing i did is that i searched for the error and it was outputed from core/lib/Drupal/Core/Form/EventSubscriber/FormAjaxSubscriber.php :: wihtin we find a condition that interests us:

if ($exception instanceof BrokenPostRequestException &amp;&amp; $request-&gt;query-&gt;has(FormBuilderInterface::AJAX_FORM_REQUEST)) {
  $this-&gt;drupalSetMessage($this-&gt;t('An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (@size) that this server supports.', ['@size' =&gt; $this-&gt;formatSize($exception-&gt;getSize())]), 'error');
  $response = new AjaxResponse();
  $status_messages = ['#type' =&gt; 'status_messages'];
  $response-&gt;addCommand(new ReplaceCommand(NULL, $status_messages));
  $response-&gt;headers-&gt;set('X-Status-Code', 200);
  $event-&gt;setResponse($response);
  return;
}


So the error is triggered if an exception instanciated of the BrokenPostRequestException class has occurred.

and now if we got to Core/lib/Drupal/Core/Form/FormBuilder.php we find that this exception is thrown if the post request is bigger than what is allowed by the server and also if the request doesn't carry the form id.

if ($ajax_form_request &amp;&amp; !$request-&gt;request-&gt;has('form_id')) {
  throw new BrokenPostRequestException($this-&gt;getFileUploadMaxSize());
}



  It would have been better if there was another exception for this case
  rather than getting the same error for when the post request exceeds
  the configured allowed size (post_max_size)


well in my case it was not a matter of post size request but rather when I themed the form in my twig file, I did not include the form id.

So what i did is i added the lines highlited bellow:

&lt;div class="fr relative filtrehold"&gt;
        &lt;div class="filtr_btn  br-pill shadow-2 ttu dark-gray f5 proximabold"&gt;Filtres&lt;/div&gt;
        &lt;form&gt; //Added this one
            {{ McRefund_build_data.filterform.form_build_id }} //Added this one
            {{ McRefund_build_data.filterform.form_id }} //Added this one
            {{ McRefund_build_data.filterform.RelevesMensuels }}
            {{ McRefund_build_data.filterform.from }}
            {{ McRefund_build_data.filterform.to }}
            {{ McRefund_build_data.filterform.example_select }}
            {{ McRefund_build_data.filterform.actions.submit }}
        &lt;/form&gt; //Added this one
&lt;/div&gt;
&lt;div class="table_hold bg-white br2"&gt;

    &lt;div id="table-wrapper"&gt;

        {% for Num_refund,refund in McRefund_build_data.filterform.RefundsContainer['Refunds']['#Refunds_data'] %}
                   ............
                   ............
                   ............
        {% endfor %}
    &lt;/div&gt;
&lt;/div&gt;