I am trying to add a Ajax Alert or popup message inside a hook_node_presave or hook_node_update, but it is not working.

My current code look like this, but I have tried a lot of other ajax

$response = new ajaxResponse();
$response->addCommand(new AlertCommand('Ajax test'));
return $response;

The node is saved but no alert and no errors in the console. Drupal 9

  • Those hooks dont return responses. api.drupal.org/api/drupal/…
    – Kevin
    Oct 21, 2021 at 18:12
  • No I understand that now. I do have a RedirectResponse that works fine when I not saving with Ajax. Oct 22, 2021 at 8:05
  • Any suggestion to how I can solve this issue? I have struggled with this for 3 days now. Everything works fine when savning from a form. Then I get at message on the page. But when saving with Ajax I want at alert or someting to popup. Oct 22, 2021 at 8:08


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.