What is the progress bar periodic update function return data? In Drupal 7 from the function called with 'url/to/call/progressbar/update/function' (see below) you would return an array converted to JSON like this:

drupal_json_output($message);


I cannot find any examples for Drupal 8 and I suspect it's an object rather than an array that gets returned.

Does anyone know how/what to return from the progress bar update function?

The setup for the bar progress indicator would be something like this:

$form['some_item'] = array(
  '#type'  =&gt; 'submit',
  '#value' =&gt; t('My action'),
  '#ajax'  =&gt; array(
    'callback' =&gt; 'a_function',
    'wrapper'  =&gt; 'ajax-response-goes-here',
    'method'   =&gt; 'replace',
    'progress' =&gt; array (
      'type'     =&gt; 'bar',
      'message'  =&gt; 'Starting...',
      'url'      =&gt; 'url/to/call/progressbar/update/function',
      'interval' =&gt; '1000'
)
The core example is in FileWidgetAjaxController::progress. You need to return a JSON-encoded associative array with message and percentage keys. For example:

$progress['message'] = t('Uploading... (@current of @total)', ['@current' =&gt; format_size($status['bytes_uploaded']), '@total' =&gt; format_size($status['bytes_total'])]);
$progress['percentage'] = round(100 * $status['bytes_uploaded'] / $status['bytes_total']);
...
return new JsonResponse($progress);