我有一个可用的 OData 端点,我可以在其中查看各个数据点。 (例如,localhost/myData/person(10) 中有第 10 个人的数据。)
但是我的 JayData javascript 中的对象值没有被填充。 当我打印时:
console.log(person[10]);
initData 中的每个对象参数都是未定义的。
我的完整脚本是:
var ctx = new WebApplication.resource_dbEntities({ name: 'oData', oDataServiceHost: 'http://localhost:8080/Resource/example.svc' });
ctx.onReady(function() {
ctx.person.toArray().then(function(person){
console.log("Person[10] is:");
console.log(person[10]);
person.forEach(function(p) {
//Always prints "undefined" :(
console.log(p.person_lastname);
});
})
.fail(function(r){
console.log(r);
});
});
更新: 服务器肯定正在发送数据 - 请参阅网页上网络面板的剪辑。
注意:我已经在 JayData forum 上发布了更多详细信息.
最佳答案
您不需要 initData。首先查看浏览器的网络面板,看看您的服务器是否发送任何数据。
关于javascript - JayData 不从 OData 填充对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17348851/