Documentation Prolog Predicate Reference js ajax/4


Perform an asynchronous HTTP (Ajax) request.


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.



Example #1 Simple AJAX request to get JSON data

?- ajax(get, '', JSON, [type(json)]), json_prolog(JSON, Prolog). % JSON = <javascript>(object), Prolog = [a-1, b-two, c-[[d-[]], [e-wow]]].