If you are writing a plugin, you will find an example on ckgedit/action/meta.php:
$controller->register_hook('AJAX_CALL_UNKNOWN', 'BEFORE', $this,'_ajax_call');
$controller->register_hook('HTML_UPDATEPROFILEFORM_OUTPUT', 'BEFORE', $this, 'handle_profile_form');
These show how to add to the profile form, and process the response. The response is created in ckgedit/script.js by the
function:
ckgedit_seteditor_priority()
which will show you how to create the ajax call that is handled by AJAX_CALL_UNKNOWN. See:
https://www.dokuwiki.org/devel:event:ajax_call_unknown