如果是角$ http呼叫

时间:2015-10-29 07:06:32

标签: angularjs http

下面是我的角度$ http CORS呼叫代码,

$http({
        method: 'GET',
        url: 'http://localhost:4808/api/User?login=' + $scope.data.LOGIN           
    }).success(function (responseData, status, headers, config) {           
        $scope.CompleteLoad();
        $scope.LoginExists = false;

    }).error(function (data, status, headers, config) {
        if (status == 409) {
            HideBlock();
            ngNotify.set("User Already Exists", 'error');
            $scope.data.id = '';
            $scope.LoginExists = true;
        }

        if (status == 401)
        {
            HideBlock();
            ngNotify.set("You are authorized.", 'error');
        }
    });  

如果由于某种原因我的$ http调用失败,我需要根据HTTP状态代码显示错误消息,但我发现“status”为-1,这不是有效的代码。

问题:请告诉我需要修改的内容,以便我获得正确的错误HTTP状态代码。

0 个答案:

没有答案