Documentation Prolog Predicate Reference js ajax/4

ajax/4

Perform an asynchronous HTTP (Ajax) request.

Description

ajax( +http_method, +atom, -term, +ajax_options )

ajax(Method, URL, Result, Options) succeeds if Result is the response from the HTTP request sent to URL using the method Method. Method must be one of the following HTTP request methods: connect, delete, get, head, options, patch, post, put or trace. The options of the HTTP request are controlled by the options from the list Options. The available values for Options can be checked in the next section.

Options

Examples

Example #1 Simple AJAX request to get JSON data

?- ajax(get, 'http://tau-prolog.org/files/sample/data.json', JSON, [type(json)]), json_prolog(JSON, Prolog). % JSON = <javascript>(object), Prolog = [a-1, b-two, c-[[d-[]], [e-wow]]].

Implementation