How do I request Prolog via Javascript?

I am using SWI-Prolog to query a WordNet database. Now I need to create an HTML interface that will take a word from the user and query it against the db.

How can I write JS code that will send a word to Prolog wrapped in a query, and how can I get the results in meaningful variables that I can display on a web page?

+3


source to share


1 answer


You might want to use the HTTP server support that comes with SWI-Prolog. Use Ajax and JSON to exchange requests and results, there is a page in the online documentation to help you get started: http://www.swi-prolog.org/pldoc/doc_for object = section? (2, '5', SWI ('/DOC/packages/http.html'))

If you don't know jQuery yet , you should check it out. It will be very easy to get Ajax calls to work, and it also contains support for handy JSON handling.



If you want to use some other web server, say Apache, there is a HowTo in the documentation as well. Good luck!

+2


source







All Articles