1
自从最近2小时以来,我一直在努力处理以下错误。我不知道什么是错的。AngularJs:“意外的输入结束”
SyntaxError: Unexpected end of input
at eval (<anonymous>)
at Function.globalEval (https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.min.js:4:4228)
at init.domManip (https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.min.js:5:20866)
at init.append (https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.min.js:5:18502)
at init.<anonymous> (https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.min.js:5:19874)
at Function.access (https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.min.js:4:5765)
at init.html (https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.min.js:5:19537)
at Object.<anonymous> (http://127.0.0.1:8887/js/angular-ui-router.min.js:7:24156)
at https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.min.js:16:71
at ta (https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.min.js:84:35) <div ui-view="" class="ng-scope">
,我只能发现,当我称之为angjs服务
app.factory("Userservice", ['$rootScope', '$http', 'GENERAL_CONFIG', 'FlashService',
function($rootScope, $http, GENERAL_CONFIG, FlashService) {
return {
FindUserDetail: function(userid) {
return $http.get(String.format('{0}/GetUserDetailById?UserId={1}',
GENERAL_CONFIG.ServiceWebApiUrl,
userid));
}
};
}
]);
在此之后发生是我的控制器代码
var userId = loggedIn.userId;
Userservice.FindUserDetail(userId).then(//this line throws error
function(data) {
if (data.data != null || data.data != undefined) {
var a = data.data.myJsonVariable //I get valid data here
}
},
function(httperror) {
FlashService.Error("Error Status Is " + httperror.status, true);
});
输入意外结束是非常通用的错误。 指导我。
它出现时,jQuery是解析您的来电'GetUserDetailById'的响应被扔。它可能会返回一个不完整或无效的json字符串。你能编辑添加来自服务器的响应吗? – Rhumborl
json响应已完成。当我在json编辑器中解析响应时,它是完整的。解析没有任何错误。即使在成功函数中,我可以访问json对象。像data.data.myJsonVariable –
你是否在此页面/控制器实例化时立即调用它?或者这是返回一些函数? – alphapilgrim