Avoid outputting the JavaScript to trigger a document change if the request is an AJAX one. It breaks the JSON serialisation in adminlinks, evidently.