My ajax callback function which is changing a form did redirect properly in the past, but now with no change to this code it does not work anymore.

function node_create_callback($form, &$form_state){
    module_load_include('inc', 'node', 'node.pages');
    node_form_validate($form, $form_state);
    if (!form_get_errors()){

      //on success submit form and redirect
      $commands =  array(ctools_ajax_command_redirect("node/"));
      return array('#type' => 'ajax', '#commands' => $commands);
      //on error display errors on form without refreshing page
      $commands = array('#type' => 'ajax', '#error' => FALSE, '#commands' => array());
      $output = drupal_render($form);
      $commands['#commands'][] = ajax_command_insert(NULL, $output);
      // Prepend status messages to the node form.
      $commands['#commands'][] = ajax_command_prepend(NULL, theme('status_messages'));
      return $commands;

1 Answer 1


instead of

return array('#type' => 'ajax', '#commands' => $commands);

try this

print ajax_render($commands);


I had a similar problem, and this code worked for me.

courtesy: Ajax redirect on successful submission is not working properly

Hope that helps!

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.