简体   繁体   中英

No response from AJAX call

I am not getting any response from my AJAX call to the API. Few days back it was working fine and I was getting response JSON but now I am not able to get any JSON object. Mozilla does not give response JSON but shows no error but in Chrome I am getting net::ERR_INSECURE_RESPONSE

AngularJS code:

app.controller("LoginCtrl",
        function($scope, $http,$location,$rootScope) {
    $scope.login = function(user){
        $http({
            method: "POST",
            url: "https://aadvq11nwbv01.staples.com/wcs/resources/v1/member/login?storeId=10101&responseFormat=json",
            /*header: "Access-Control-Allow-Origin:*",*/
            header: "Content-Type: application/json",
            header: "Accept: application/json",
            data:{
                companyID: $scope.user.customerid,
                userID: $scope.user.userid,
                password: $scope.user.password
            }
        })
        .success(function (response){
            $rootScope.profile="xxx";
            userDetails = response;
            console.log(userDetails);
            $location.url("/profile")
        })
        .error(function (err){
            $scope.logerr="err";
            console.log(err);
        });
    }
});

The reason could be you have specified in wrong way. header should be an object then define its properties in it.

Code

    $http({
        method: "POST",
        url: "https://aadvq11nwbv01.staples.com/wcs/resources/v1/member/login?storeId=10101&responseFormat=json",
        header: {
            "Content-Type: application/json",
            "Accept: application/json"
        },
        data:{
            companyID: $scope.user.customerid,
            userID: $scope.user.userid,
            password: $scope.user.password
        }
    })

The reason you get the error is that the SSL certificate provided by the webserver is not recognised and therefore not trusted. If you are using a self-signed certificate on your webserver this will explain it. Otherwise there is an issue with the setup of your certificate.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM