我正在升级我的网站。我升级到AngularJS v1.7.6和JQuery v1.12.1 我在控制台日志中收到此错误消息。
TypeError: Cannot read property 'CustomerId' of undefined
我所做的就是将.success更改为.success,然后将.success贬值。
这是我进行更改的代码。因此,我相信data [0]为null,因此没有属性CustomerId。此函数适用于我的旧版本的jquery和.success而不是.then方法的angular
我不确定该怎么做...(在这里圈出一个圆圈)
$scope.sessionDetails = function () {
urlService.dataProvider(sessionMethod, "POST", '').then(function (data) {
$scope.sesCustomerId = data[0].CustomerId;
$scope.sesToken = data[0].Token;
$scope.sesCustomerName = data[0].CustomerName;
$scope.sesUserIsMember = data[0].IsMember;
$scope.userEmail = data[0].Email;
var indexFavUrl = wLArray.indexOf("Favourites");
if (wLArray[indexFavUrl] == "Favourites") {
if ($scope.sesCustomerId != '') {
//Getting User Favourite Items with customer Id
$scope.GetFavouriteItems($scope.sesCustomerId);
}
}
/* To Open Popup after login */
if (sessionStorage.getItem("CustomPro") == "fromCompse") {
if (!sessionStorage.getItem("UMBID")) {
var cprt = window.location.search.split("=")[1];
var isprodmemonly = window.location.search.split("=")[2];
}
else {
var cprt = sessionStorage.getItem("UMBID");
var isprodmemonly = sessionStorage.getItem("UMBID_IsMem") == "true" ? true : false;
}
show();
if ($scope.sesUserIsMember != "1" && isprodmemonly) {
jAlert('This Product is only for members.');
sessionStorage.removeItem("CustomPro");
return false
} else {
$scope.ProductCompose(cprt, '', cprt, isprodmemonly);
}
}
});
}
$scope.sessionDetails();
答案 0 :(得分:0)
对于jQuery,您需要将.success()
替换为.done()
而不是.then()