BT

datajs– Using OData From Within the Browser

by Abel Avram on Feb 09, 2011 |

Microsoft has created a JavaScript library enabling developers to consume OData from within the browser.

The Open Data Protocol (OData) is a protocol created by Microsoft enabling the consumption of data in a RESTful way based on HTTP, AtomPub and JSON. datajs is an open source cross-browser JavaScript library, also released by Microsoft, easing the task of developers to access OData from within the browser. datajs will be enhanced in the future to access HTML5 functionality exposed by browsers.

The datajs API currently contains two main functions:

OData.read = function (url | request, [success(data, response)], [error(error)], [handler], [httpClient], [metadata])

OData.read is used to retrieve data from an OData-enabled service as an AtomPub feed or a JSON document. The library uses a RESTful convention, accessing each resource through an URI. The developer may specify a handler for errors, and another for content received from the service.

OData.request = function (request, [success(data, response)], [error(error)], [handler], [httpClient], [metadata])

OData.request is used to add new data, to update or to delete existing data. Besides functionality similar to OData.read, OData.request can be used to send data in batches.

datajs uses XMLHttpRequest to make network calls by default, but a different HTTP client can be used.

Microsoft plans to enhance datajs to access HTML5 functionality in the future such as the local storage provided by IndexedDB.

OData is offered by Microsoft under the Microsoft Open Specification Promise (OSP), and currently implemented by Microsoft across a number of Azure services, by Netflix, Facebook, ebay and others. datajs is offered under the MIT License (MIT).

Hello stranger!

You need to Register an InfoQ account or to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2013 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT