The action function that you posted is not making any changes to fields. It is attempting to create output that is sent to the browser. Output is not created and sent to the browser during the update process. Trying to do so is likely creating causing errors.