You can get the lock status from the checklock function:
https://xref.dokuwiki.org/reference/dokuwiki/inc/common.php.source.html#l895
You can't check lock status from the browser without an ajax call, which requires server side access. For this you will need a plugin (preferably) or a server side script called from your ajax function. For the plugin, see the
ajax_call_unknown event and the example linked to at the bottom of that page.