In this OnLamp.com article, Nic Ferrier explains how to use simple Ajax techniques to interface with a remote REST (Representational State Transfer) web service.

Everyone’s talking about REST these days. Lots of people are still struggling with it, and there’s good reason for that–REST is actually quite difficult to fit into the browser-based HTML Web. As far as I’m concerned, this is fair enough; REST is primarily a web services platform, an alternative to CORBA, SOAP, and XMLRPC, not a user interface. Still, at least some of the time, it’s nice to use a REST API as the foundation for a webapp. On the other hand, Ajax can be really complicated, and it always seems to involve lots of different bits of code.

That is the point of this article. REST’s clean definition of an application’s architecture solves at least some of the problems with Ajax; and using Ajax to a REST webapp leaves the REST API uncomplicated and pure.

They detail the implementation of a REST web service as written in Python, including in it the ability to manage a user’s feeds through various HTTP methods (GET, POST, and DELETE) and calls. There is a block of code for each that performs the operation based on the input parameters (or lack thereof).

Last, but not least, they show the simple Ajax implementation – creating the XMLHttpRequest object “by hand” – that can make the requests to the web service. It’s then possible to visually manage the feeds via the list contained in the form with checkboxes to the side of each.

We use cookies and other similar technologies (Cookies) to enhance your experience and to provide you with relevant content and ads. By using our website, you are agreeing to the use of Cookies. You can change your settings at any time. Cookie Policy.