角Js后操作'500(内部服务器错误)'错误?
问题描述:
createEmpModule.controller('createEmpCtrl', function ($scope, $http) {
$scope.listDatas = function() {
$http.post("/Common/Common/GetLanguages").then(function (result) {
$scope.list = result;
});
}
$scope.listDatas();
});
angular.min.js:9827 POST http: //localhost:xxxxx/Common/Common/GetLanguages 500 (Internal Server Error)
角错误行:
xhr.send(post || null);
所以,函数返回返回值,
答
跳到我面前的第一件事是,您正在制作$http.post()
而不发送任何数据。
$scope.listDatas = function() {
$http.post("/Common/Common/GetLanguages", [dataObjectGoesHere]).then(function (result) {
$scope.list = result;
});
}
我的猜测是你想用.get()代替。
$scope.listDatas = function() {
$http.get("/Common/Common/GetLanguages").then(function (result) {
$scope.list = result;
});
}
第二件事我要说的是检查服务器错误日志!他们将掌握造成你的500错误的关键。我愿意下注$ 1.00,表示您在尝试将数据发送到无法预期GET请求的位置时发生错误。
答
我发现了一个错误解决方案。 它不是来自控制对象的对象类型。 我创建了一个新的模型,我解决了。
'/'应用程序中的服务器错误。
? ? 类型'System.Collections.Generic.Dictionary`2 [[System.SByte,mscorlib,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089],[System.String,mscorlib,Version = 4.0.0.0,Culture =中性,PublicKeyToken = b77a5c561934e089]]'不支持序列化/反序列化字典,键必须是字符串或对象。
更像是服务器端的问题。 – Icycool
至少做了一个搜索,以找出500错误意味着什么! – charlietfl
我已经探索过了。说你知道。 –