OData Code Snippets

This topic provides some snippets to help you get up and running quickly when using the datajs OData support.

Reading and displaying data
The following snippet shows how to read a list of category names from the Northwind service, using jQuery to add them to an element with ID 'target-element-id'. Because the service supports JSONP, the default network library uses it even though the
document comes from a different domain.

Adding data in batches
The following snippet shows how to add and cross-reference a Customer and an Order. Note that the first request includes a header for "Content-ID", and the second request references the newly added customer as "$1".

There's an error in the first sample - the first parameter of the callback of the jQuery each function is the index of the current element. It should read:$.each(data.results, function(ix, l) { html += "<div>" + l.CategoryName + "</div>"; });

thanks for the example, a few questions about the example, the current read more function does not have a callback function, which I cannot catch the complete event. should I add an function parameter? 2. If I have more than 1 read more calls on the page, the global result array will cause problem. should I also create a parameter for it?