BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News datajs– Using OData From Within the Browser

datajs– Using OData From Within the Browser

This item in japanese

Bookmarks

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
Style

BT