This project is read-only.

Read Data Sample

This topic provides a simple scenario that leverages the OData support in datajs to search for videos.

This sample demonstrates the following.
  • Using datajs with jQuery and jQuery templates.
  • Building a URI to customize a read request: asking for specific properties, searching for keywords, sorting the results.
  • Reading data through datajs and handling success and error cases.

Download sample.htm.

Last edited Jun 18, 2011 at 1:13 AM by marcelolr, version 3


DanKline Jun 11, 2013 at 9:30 PM 
I'm sucessfully building the URL and submitting the request using 1-1beta2, but I'm seeing this response:

HTTP/1.1 400 Bad Request
Content-Length: 176
Content-Type: application/json
Server: Microsoft-IIS/7.5
DataServiceVersion: 1.0;
X-Powered-By: ASP.NET
Date: Tue, 11 Jun 2013 20:26:45 GMT

"error": {
"code": "", "message": {
"lang": "en-US", "value": "The query parameter '$callback' begins with a system-reserved '$' character but is not recognized."

slapointe Apr 25, 2013 at 8:33 PM 
I set OData.defaultHttpClient.enableJsonpCallback = false; and everything started to work.
I don't why. As I read I'll try to understand.

FloK Jan 17, 2013 at 10:06 AM 
The example doesn´t work for me. When i´m searching for "HTML" Firebug shows me:

"NetworkError: 400 Bad Request -$select=Name,Description,ImageUrl,Url&$top=50&$orderby=DatePublish%20desc&$filter=substringof(%27HTML%27,%20Description)&$callback=parent.handleJSONP_0&$format=json"

Any ideas?

regards FloK

nohorse Aug 25, 2011 at 5:17 PM 
you are not referencing the CDN for this example so it's not a self contained. please update to use CDN and host a CDN if you don;t have one yet.

kashyapa Jul 3, 2011 at 9:32 PM 
Here is "Digging deep inside - Read Data Sample" article that i wrote.


marcelolr Jun 21, 2011 at 6:28 PM 
Go ahead Lohith, we can certainly link to it at least.

I struggled myself with how much content to present in the sample - a bit of URL building seemed appropriate to show how to encode string literals and escape them correctly, but I'm already worried that the datajs-ness might get diluted.

Having more advanced end-to-ends available (i.e., solving "more real" problems) can only help.


kashyapa Jun 21, 2011 at 8:27 AM 

Can i extend this sample ?

With the demo code you guys have done, the search for the string in the description is doing as a case sensitive search.

What i have in mind is a case insensitive search + provide option to search by all words or any words. I have it ready. I will blog about it and may be you guys can review the code and a take a call.

Do let me know on this ?