Is it possible to return a form element AND an ajax response from the same ajax callback function? I have an ajax callback function that needs to return a form element and also an ajax response. Is it possible to do both?
In my callback I need to set and return something like:
$form['fid'] = array(
  '#type' =&gt; 'textfield',    
  '#value' =&gt; 1,
);
return $form['fid'];

And also something like:
   $response = parent::uploadAjaxCallback($form, $form_state, $request);
   return $response;

Is there a way that I can achieve return both a form element and an ajax response?
EDIT: Latest attempt is returning the form element for display but when I examine the $form from the form build function the value is still empty.
class MyManagedFile extends ManagedFile {

  /**
   * {@inheritdoc}
   */
  public static function uploadAjaxCallback(&amp;$form, FormStateInterface &amp;$form_state, Request $request) {


    $response = parent::uploadAjaxCallback($form, $form_state, $request);

    $form['fid'] = array(
      '#type' =&gt; 'textfield',
      '#prefix' =&gt; '&lt;div id=&quot;fid&quot;&gt;',
      '#suffix' =&gt; '&lt;/div&gt;',
      '#value' =&gt; '1',
    );

    $response-&gt;addCommand(new ReplaceCommand('#fid', $form['fid']));
    return $response;

  }

}

Examining the $form from the form builder (dpm($form)) results in:
[fid] =&gt; Array
(
[#type] =&gt; textfield
[#prefix] =&gt;
        [#suffix] =&gt; 

    )
If you want to do more than simply return new markup, then your response should be an instance of Drupal\Core\Ajax\AjaxResponse, to which you can append one or more AJAX commands via the addCommand() method.
A simplified version of this would be:
use Drupal\Core\Ajax\AjaxResponse;
$response = new AjaxResponse();
$response-&gt;addCommand(new ReplaceCommand('#my-wrapper-id', $form['fid']));
return $response;

I recommend checking out a tutorial, such as one of those below, for more information on using AJAX with FAPI:

https://www.sitepoint.com/using-ajax-forms-drupal-8/
https://www.drupal.org/docs/drupal-apis/ajax-api/core-ajax-callback-commands