FWIW, I have a simple example program of a Javascript web front-end communicating with a SWI-Prolog backend, using JSON (and Javascript “fetch”). There’s a bit of discussion here: Simple Prolog server with JavaScript client
and the repo is here: GitHub - kamahen/swipl-server-js-client: Sample SWI-Prolog server with JavaScript client