How to disable page redirect on node edit? Thank you for reading my question.

I have a node type and all I want is it not to redirect to the node on edit submission.

Currently, when on the node edit page submissions are sent through ajax, however when the node is submitted it also redirects to the node page, making the ajax pointless :( ...

How do I stop the edit page redirecting on submission.

Thanks for any help
I am not sure what the ajax is doing in your specific case, but if all you want to do is redirect back to the node/###/edit page instead of node/###, you are wanting to swap out the submit handler with one that doesn't do the redirect.

The core one, assuming your hook-nodeapi tag implies Drupal 6 anyway, looks like this....

function node_form_submit($form, &amp;$form_state) {
  global $user;

  $node = node_form_submit_build_node($form, $form_state);
  $insert = empty($node-&gt;nid);
  node_save($node);
  $node_link = l(t('view'), 'node/'. $node-&gt;nid);
  $watchdog_args = array('@type' =&gt; $node-&gt;type, '%title' =&gt; $node-&gt;title);
  $t_args = array('@type' =&gt; node_get_types('name', $node), '%title' =&gt; $node-&gt;title);

  if ($insert) {
    watchdog('content', '@type: added %title.', $watchdog_args, WATCHDOG_NOTICE, $node_link);
    drupal_set_message(t('@type %title has been created.', $t_args));
  }
  else {
    watchdog('content', '@type: updated %title.', $watchdog_args, WATCHDOG_NOTICE, $node_link);
    drupal_set_message(t('@type %title has been updated.', $t_args));
  }
  if ($node-&gt;nid) {
    unset($form_state['rebuild']);
    $form_state['nid'] = $node-&gt;nid;
    $form_state['redirect'] = 'node/'. $node-&gt;nid;
  }
  else {
    // In the unlikely case something went wrong on save, the node will be
    // rebuilt and node form redisplayed the same way as in preview.
    drupal_set_message(t('The post could not be saved.'), 'error');
  }
}


So, if you created almost a duplicate of it in a custom module...

function YOURMODULE_node_form_edit_submit($form, &amp;$form_state) {
  global $user;

  $node = node_form_submit_build_node($form, $form_state);
  $insert = empty($node-&gt;nid);
  node_save($node);
  $node_link = l(t('view'), 'node/'. $node-&gt;nid);
  $watchdog_args = array('@type' =&gt; $node-&gt;type, '%title' =&gt; $node-&gt;title);
  $t_args = array('@type' =&gt; node_get_types('name', $node), '%title' =&gt; $node-&gt;title);

  if ($insert) {
    watchdog('content', '@type: added %title.', $watchdog_args, WATCHDOG_NOTICE, $node_link);
    drupal_set_message(t('@type %title has been created.', $t_args));
  }
  else {
    watchdog('content', '@type: updated %title.', $watchdog_args, WATCHDOG_NOTICE, $node_link);
    drupal_set_message(t('@type %title has been updated.', $t_args));
  }
  if ($node-&gt;nid) {
    unset($form_state['rebuild']);
    $form_state['nid'] = $node-&gt;nid;
    // $form_state['redirect'] = 'node/'. $node-&gt;nid; // just remove or comment out this line
  }
  else {
    // In the unlikely case something went wrong on save, the node will be
    // rebuilt and node form redisplayed the same way as in preview.
    drupal_set_message(t('The post could not be saved.'), 'error');
  }
}


with the only change being the removal or commenting out of the redirect, you are halfway there.  Now you need to have this one called when you are editing nodes, which is done with a form_alter, something along these lines...

function YOURMODULE_form_alter(&amp;$form, $form_state, $form_id) {

  if ($form_id=='TYPE_node_form') { // TYPE is the machine name of the content type you are dealing with here

    if (arg(2)=='edit') {

      foreach ($form['buttons']['submit']['#submit'] as $h =&gt; $handler) {
        if ($handler=='node_form_submit') {
          $form['buttons']['submit']['#submit'][$h]='YOURMODULE_node_form_edit_submit';
        }
      }

    }

  }

}


and now, assuming no copy/paste typos, you should be able to edit that node type and if you hit submit, it does not redirect to the node page but rather redirects back to the node/#/edit page.

Now, if somehow your ajax stuff is doing something similar like swapping out the various handlers, then you will have to do something different yet similar, and the above should be able to guide you a bit.  (The point I am trying to make here is that hitting submit causes drupal to go to/load another page unless that button itself has been ajaxed or otherwise modified)

UPDATE:

I changed the name of the handler from YOURMODULE_node_form_submit to YOURMODULE_node_form_edit_submit because, as I just found out, if you happen to have a module and content type of the same name, drupal goes all recursive on you upon trying to submit the edits of those node types due to hooking into TYPE_node_form_submit automatically.