获取500 - 内部服务器错误与实体框架的Ajax Jquery方法
问题描述:
我做了this tutorial与SQL数据库和实体框架和Knockout.js温暖。获取500 - 内部服务器错误与实体框架的Ajax Jquery方法
我想我可以安排代码连接到我自己的数据库。
为了开发基于web应用MVVM这是视图模型:
[视图模型与观测在Javascript中调用由Knockout.js]
function Device(data) {
this.Date = ko.observable(data.Date);
this.Value = ko.observable(data.Value);
this.ObjectID = ko.observable(data.ObjectID);
this.TypeID = ko.observable(data.TypeID);
}
function DeviceViewModel() {
var self = this;
self.Devices = ko.observableArray([]);
self.Date = ko.observable();
self.Value = ko.observable();
self.ObjectID = ko.observable();
self.TypeID = ko.observable();
$.ajax({
type: "POST",
url: 'LearnKO.aspx/FetchDevices',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (results) {
var devices = $.map(results.d, function (item) {
return new Device(item)
});
self.Devices(devices);
},
error: function (err) {
alert(err.status + " - " + err.statusText);
}
})
}
$(document).ready(function() {
ko.applyBindings(new StudentViewModel());
});
AJAX的方法应该调用一个WebMethod在.aspx。 CS数据:
[WebMethod]
public static DEVICE_VALUES[] FetchDevices()
{
DiagmaResultsEntities dbEntitiesDiagma = new
DiagmaResultsEntities();
var dataDiagma = (from item in dbEntitiesDiagma.DEVICE_VALUES
orderby item.Value
select item).Take(12);
return dataDiagma.ToArray();
}
,这是我的SQL数据库: enter image description here
我想从EF中获取“date”,“value”,“ObjectID”和“typeID”。但即时通讯这个错误,并找不到自己与谷歌可能的解决方案。
答
我解决给予了响应体我的问题,觉得我有说:
$.ajax({
method: "POST",
url: 'LearnKO.aspx/FetchDevices',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (results) {
var devices = $.map(results.d, function (item) {
return new Device(item)
});
self.Devices(devices);
},
error: function (err) {
//alert(err.status + " - " + err.statusText);
console.log(err.status + " - " + err.statusText);
console.log(err.responseText);
}
});
我得到了以下错误代码: errorcode
的JSON序列似乎有“循环参考”的问题。
通过从这些数据库中只添加一个表结束,并能够显示我的数据。
感谢您的帮助。
什么是错误? – john
jquery抛出一个异常,并弹出消息框:“500 - 内部服务器错误” –
那么,ASP.NET通常会给出一个响应正文,提供关于错误的信息,或者如何打开显示错误信息。阅读回复。 – john