BT

New Early adopter or innovator? InfoQ has been working on some new features for you. Learn more

datajs– Using OData From Within the Browser

| by Abel Avram on Feb 09, 2011. Estimated reading time: 1 minute |

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).

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login 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

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT