In my previous post we were talking about how to create a REST web service. But now we want to build a client and consume this service.

The address was http://localhost/DbUsersApi.php?action=get_user_list and the result was a JSON file:


We will use a simple HTML file with Javascript.

Consume the service with Javascript:

Create a new file in your WWW folder and name it RestJSClient.html

Load the HTML file in your browser. If you are in Chrome then click on the menu button, then More Tools and Developer Tools, then select the Console tab.

This is the result from the Console:

Javascript Console