Javascript / PHP – closing the loop

Perhaps you could either use admin ajax or the WP REST API to send a request to the server for the user meta update.

If you have a look at the WP documentation (links above) or similar questions here on WPSE, you can find examples on how to do it.

  1. Update user meta with ajax https://wordpress.stackexchange.com/search?q=Update+user+meta+ajax
  2. Update user meta with rest api https://wordpress.stackexchange.com/search?q=Update+user+meta+via+REST+API%3F