简体   繁体   English

使用DataJS消耗OData Servie

[英]Consuming OData Servie using DataJS

I have this javascript code in MVC view i try to call OData Service using Datajs : 我在MVC视图中有此javascript代码,我尝试使用Datajs调用OData服务:

$(document).ready(function() {
     var temp = OData.read("http://odata.netflix.com/v1/Catalog/Genres", function (data,  response) {
     var x = 3;

      });
});

i have a break-point on var x = 3; 我在var x = 3;上有一个断点var x = 3; but unfortunately the break-point was never hit! 但不幸的是,从未达到过断点! if i put break-point on OData.Read i can see its calling the OData-Service but then the callback function never get fired , i dont know what im doing wrong? 如果我在OData.Read上设置OData.Read我可以看到它在调用OData-Service,但是回调函数永远不会触发,我不知道我在做什么错?

Add this before calling OData.Read() : 在调用OData.Read()之前添加此OData.Read()

OData.defaultHttpClient.enableJsonpCallback = true;

Also your request doesn't specify format. 另外,您的请求未指定格式。 Change the request string to: http://odata.netflix.com/v1/Catalog/Genres?$format=json&$callback=?callbackHere 将请求字符串更改为: http : //odata.netflix.com/v1/Catalog/Genres?$format=json&$callback=?callback此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM