Javascript TypeError:无法读取属性';客户ID';未定义的

Javascript TypeError:无法读取属性';客户ID';未定义的,javascript,jquery,angularjs,Javascript,Jquery,Angularjs,我正在升级我的网站。我升级到AngularJSV1.7.6和JQuery v1.12.1 我在控制台日志中收到此错误消息 TypeError: Cannot read property 'CustomerId' of undefined 我所做的只是改变。成功变成了。然后,成功被贬低了 这是我更改代码的地方。因此,我认为数据[0]为空,因此没有属性CustomerId。此函数将与我的旧版本jquery一起使用,并使用.success而不是.then的方法 我不知道该怎么做才能解决这个问题…(在

我正在升级我的网站。我升级到AngularJSV1.7.6和JQuery v1.12.1 我在控制台日志中收到此错误消息

TypeError: Cannot read property 'CustomerId' of undefined
我所做的只是改变。成功变成了。然后,成功被贬低了

这是我更改代码的地方。因此,我认为数据[0]为空,因此没有属性CustomerId。此函数将与我的旧版本jquery一起使用,并使用.success而不是.then的方法

我不知道该怎么做才能解决这个问题…(在这里转圈)


对于jQuery,您需要将
.success()
替换为
.done()
而不是
。然后()

对于jQuery,您需要将
.success()
替换为
.done()
而不是
。然后()

请控制台记录数据,如果
urlService.dataProvider
data[0]中的响应数据为空,则它可能是响应对象而不是实际数据。CustomerId
将导致此错误。您需要先检查数据[0]是否存在,然后再设置值请参见console.log数据。如果响应数据在
urlService.dataProvider
数据[0]中为空,则它可能是响应对象而不是实际数据。CustomerId
将导致此错误。在设置值之前,需要检查数据[0]是否存在。因此,将.success()替换为.done(),将.error()替换为.fail()。更多细节可以在这里找到:好的。因此,将.success()替换为.done(),将.error()替换为.fail()。更多详细信息可在此处找到:
$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();